LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   XML parsing using DOM & Xerces on C++ (https://www.linuxquestions.org/questions/linux-software-2/xml-parsing-using-dom-and-xerces-on-c-698971/)

amitpardesi 01-21-2009 05:15 PM

XML parsing using DOM & Xerces on C++
 
Hi,

We developing a product where we are reading an tchar *buffer which is in XML format. The XML is a nested XML tree. I need to traverse this XML recursively to create various required obj from the XML string.

I am using XercesC 2.8 for the same. I am able to pare & fetch simple XML tree and create back the XML buf from the object info. For eg. from the below mentioned XML I can create an Object of class CHouse & vice-a-versa
<Root>
<HouseInfo>
<HouseOwner>Amit P</HouseOwner>
<HouseNo>34</HouseNo>
<HouseStreet>ABC Hw</HouseStreet>
<HouseAdd1>asjas asf</HouseAdd1>
</HouseInfo>
</Root>

But when the XML complicates like:
<Root>
<City>
<Area1>
<HouseInfo>
<HouseOwner>Amit P</HouseOwner>
<HouseNo>34</HouseNo>
<HouseStreet>ABC Hw</HouseStreet>
</HouseInfo>
<HouseInfo>
<HouseOwner>Tom H</HouseOwner>
<HouseNo>4G</HouseNo>
<HouseStreet>VHA NHw</HouseStreet>
</HouseInfo>
</Area1>
<Area2>
...
</Area2>
</City>
<Feature>
...
</Feature>
</Root>

How do I parse it using Xerces. I am facing problem when I try to get the inner XML, say I hot the node of Tag "City", then there are two Tags by the name "Area1" & "Area2" which are to be converted into Object of some class.

If anyone has worked on XercesC please help me.

Any pointers on this would be appreciated. I have searched a lot on web, but could not find any thing relevant. Even the smaples of Xerces are of no help :(

Plzz Help!!!

Regards,
Amit


All times are GMT -5. The time now is 03:58 PM.