Hi;

I have an XML document , and I need to go thorugh all the nodes and get the values and store it in an object. I need to traverse through all the nodes and get the values. How do I do it.

This is my XML . Please help

<?xml version="1.0" encoding="UTF-8"?>
<intf:getUserAndProfileResponseTest>
<intf:status>SUCCESS
</intf:status>
<intf:message/>
<model:user>
<model:givenName>Lary</model:givenName>
<model:middleName/>
<model:familyName>Ford</model:familyName>
<model:dob/>
<model:gender/>
<model:preferredLocale>en_US</model:preferredLocale>
<model:timeZone>America/Los_Angeles</model:timeZone>
<model:userId>testuser</model:userId>
<model:addresses><model:Address>
<model:line1>-</model:line1>
<model:line2>-</model:line2>
<model:line3>-</model:line3>
<model:state>-</model:state>
<model:zip>-</model:zip>
</model:Address></model:addresses>
<model:phoneNumbers>
<model:phoneNumber>
<model:verified>true</model:verified>
<model:optOut>false</model:optOut>
<model:disconnected>false</model:disconnected>
<model:nickName/>
<model:countryCode>1</model:countryCode>
<model:areaCode>423</model:areaCode>
<model:number>5768332</model:number>
</model:phoneNumber>
</model:phoneNumbers>
<model:emailAddresses/>
</model:user>
</intf:getUserAndProfileResponseTest>

Well, what programming language are you using to access your XML file? In other words, are you writing a program or just using some basic XML editor to perouse your file? At any rate as an example your XPath Query would look like the following.

1. If you wanted to look up the preferredLocale - /intf:getUserAndProfileResponseTest/model:user/model:preferredLocale
2. If you wanted to look up the userId - /intf:getUserAndProfileResponseTest/model:user/model:userId

Etc, etc.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.