[xml] Need help extracting parts of XML doc while parsing
- From: "Jones, Mark A (Mark)" <jones lucent com>
- To: xml gnome org
- Cc: "Jones, Mark A (Mark)" <jones lucent com>
- Subject: [xml] Need help extracting parts of XML doc while parsing
- Date: Wed, 7 Apr 2004 10:14:34 -0400 
Hi,
Below is a snippet of some of code I am writing to parse a SOAP/XML document.  I currently ignore unknown 
elements (those I don't care about) and their respective XML subtrees.  Instead of ignoring these unknown 
elements' subtrees,  I would like to store each one in a C++ string or C character array.  Is there a way to 
do this?  I'm envisioning an API like:
string unknown_element = string(xmlTextReaderRead_subtree(reader));
where xmlTextReaderRead_subtree(reader)returns an xmlChar pointer to the segment of the XML document that 
would comprize the subtree of the current element.
eg, if the <detail> element in my SOAP Fault message looks like
<detail> blah, blah, blah, ... </detail>
then after invoking the API xmlTextReaderRead_subtree(), my string unknown_element, should contain the 
characters "blah, blah, blah, ... ".
Any help would be appreciated.
...
while (ret == 1)                                                        
{                                                                       
    type = processNode(reader, &halt);                                  
                                                                        
    if ( halt != 0 )                                                    
        break;          // major problem                               
                                                                        
    if ( type == UNSUPPORTED )  // skip entire subtree for this element 
        ret = xmlTextReaderNext(reader);                                
    else                                                                
        ret = xmlTextReaderRead(reader);                                
}
....
Thanx,
M. Jones
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]