Xml beginner problem

Joined
Jun 23, 2008
Messages
3
Reaction score
0
Hello,

I'm trying to parse an XML document.
I found a solution using sax that
works pretty well:
if(firstPersonNode.getNodeType() == Node.ELEMENT_NODE){

Element firstPersonElement = (Element)firstPersonNode;

NodeList firstNameList = firstPersonElement.getElementsByTagName("FirstName");
Element firstNameElement = (Element)firstNameList.item(0);
NodeList textFNList = firstNameElement.getChildNodes();
patient.firstName = ((Node)textFNList.item(0)).getNodeValue().trim();
.......

Now I need to read the fields in the XML files that are shaped like this:

<Transaction>
<Item>
<ID Country="US" IDSystem="IdSys">11321</ID>
<ItemType>
<ID Country="US" IDSystem="Sys">70</ID>
<Description Language="EN">Weight</Description>
</ItemType>
<ItemContent DataType="NM" Units="kg">75</ItemContent>
</Item>
<Item>
<ID Country="US" IDSystem="IdSys">11321</ID>
<ItemType>
<ID Country="US" IDSystem="Sys">80</ID>
<Description Language="EN">Height</Description>
</ItemType>
<ItemContent DataType="NM" Units="cm">180</ItemContent>
</Item>
</Transaction>


I can't seem to find out how this is done.
Can somebody please point me in the right direction?
I'm not sure of the right search terms to google for this

Thanks in advance!
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,010
Latest member
MerrillEic

Latest Threads

Top