Jump to content

xml parsing


gimpmaster3201

Recommended Posts

Hi, I am new to this forum.

I was wondering if anyone could help me with a problem I am having with parsing a xml file from a HTTP XML request.

I have all the basics of the request working it’s just the extracting of an xml element I need help with.
In the JavaScript I parse the xml file that I receive, then this allows me to use the function getElementsByName()
If I enter a name of the element of a simple xml file then it all works ok, for example

xml file:

[i]<note>hello</note> [/i]

I then getElementsByName("note") I will be returned with the word ‘hello’



But the problem I am having is when the xml document has a namespace associated with it.
This is the xml file I want to parse

[i]<zs:searchRetrieveResponse>
<zs:version>1.1</zs:version>
<zs:numberOfRecords>2152</zs:numberOfRecords>
</zs:searchRetrieveResponse>[/i]

The data that I want from it is the numberOfRecords element, if I parse this file without the namespace it works fine, but for some reason when I try to parse the file with the name space and use the getElementsByName function and I use the string "zs:numberOfRecords" it wont work.

If anyone could help with this problem it would be greatly appreciated.
Link to comment
https://forums.phpfreaks.com/topic/30505-xml-parsing/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.