XML : Xerces: Get the raw XML for a particular DOMElement

I am using Xerces-C DOMLSParser to parse an XML Input source, and get a DOMDocument tree. I am navigating to a particular DOMElement. I wish to get the raw XML string for that element and its sub-elements.

For an XML such as the following:

  <positionreport>    <config lastupdate="1114600280">       <login user="some name" password="cleartext" />      <reports>       <report tab="1" name="Report One" />       <report tab="2" name="Report Two" />       <report tab="3" name="Third Report" />       <report tab="4" name="Fourth Report" />       <report tab="5" name="Fifth Report" />      </reports>    </config>  </positionreport>    

I get a DOMDocument from DOMLSParser::parse() and let's say that I navigate to the DOMElement corresponding to the element 'Reports'. How can I generate the raw XML string for this node i.e.:

  <reports>   <report tab="1" name="Report One" />   <report tab="2" name="Report Two" />   <report tab="3" name="Third Report" />   <report tab="4" name="Fourth Report" />   <report tab="5" name="Fifth Report" />  </reports>    

Is there any way to do this? If it cannot be done from DOMElement, DOMDocument, DOMLSParser, is there any way I can do this using any other types without having to serialize again?

No comments:

Post a Comment