Parse XML document

R

Ron Harter

I have an XML DOM that contains a response from a server
it looks somethng like this:

<?xml version="1.0"?>
<a:multistatus xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/"
xmlns:e="urn:schemas:httpmail:" xmlns:d="urn:schemas:mailheader:"
xmlns:c="xml:" xmlns:f="urn:schemas-microsoft-com:eek:ffice:eek:ffice"
xmlns:a="DAV:">
<a:response>
<a:href>SomeData/a:href>
<a:propstat>
<a:status>HTTP/1.1 200 OK</a:status>
<a:prop>
<a:href>SomeData</a:href>
<a:uid>AQEAAAAACKqfAAAAAAAAAAAAAAAA</a:uid>
</a:prop>
</a:propstat>
<a:propstat>
<a:status>HTTP/1.1 404 Resource Not Found</a:status>
<a:prop>
<d:cc/>
</a:prop>
</a:propstat>
</a:response>
<a:response>
<a:href>SomeMoreData</a:href>
<a:propstat>
<a:status>HTTP/1.1 200 OK</a:status>
<a:prop>
<a:href>SomeMOreData</a:href>
<a:uid>AQEAAAAACKqgAAAAAAAAAAAAAAAA</a:uid>
</a:prop>
</a:propstat>
<a:propstat>
<a:status>HTTP/1.1 404 Resource Not Found</a:status>
<a:prop>
<d:cc/>
</a:prop>
</a:propstat>
</a:response>

There can be an arbitrry number of response elements in the document.
I am able to get the number of responses elements in the document so I can
llop through each on the responses
nodes. The problem I have is I can't figure out how to access the named
elements inside the nodelist that i create

Am I going about this the wrong way? How do I access the elements by name in
each seperate response element tree?

I am using MSXML to do this
 
K

Keith M. Corbett

[email protected]...
There can be an arbitrry number of response elements in the document.
I am able to get the number of responses elements in the document so I can
llop through each on the responses
nodes. The problem I have is I can't figure out how to access the named
elements inside the nodelist that i create


This is a FAQ, and you can find many examples by googling on the DOM API
method names. Unfortunately that doesn't help if you don't know which
methods to apply. :)

Here's the basic pattern: Iterate over the node list, and for each node,
check its nodeType(). If it is of type ELEMENT_NODE, identify its nodeName()
(element or "tag" name). For each "interesting" element node, get its
children using getChildNodes() (for its first level children) or
getElementsByTagName() (named elements at any depth).

HHH

/kmc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top