troubleshooting Question

Xerces-c Parsing

Avatar of rajiv_ncstian
rajiv_ncstian asked on
1 Comment1 Solution952 ViewsLast Modified:
I m newbie in the world of XML. I am using Xerces-c parser to parse and get the value of given XML file. I am having xml file like:

      <Rule id="2">

I am assigning the DomentElement( Root of the Dom Tree) on DomNode, after parsing the XML file. I am using the loop to get the all elements of root like :
        DOMNode* child;
        for (child = pdnNode->getFirstChild(); child != 0; child=child->getNextSibling()){ //Here pdnNode is pointing to the Root firsttime
                                char *nodeName = XMLString::transcode(child->getNodeName());
                                int nodeType = child->getNodeType();
                                XERCES_STD_QUALIFIER cout <<"-------------------------------------------------------"<<XERCES_STD_QUALIFIER endl;
                                XERCES_STD_QUALIFIER cout <<"Encountered Element : "<< nodeName <<" and Type : "<< nodeType << XERCES_STD_QUALIFIER endl;

After executing I am Getting output like.

Encountered Element : #text and Type : 3
Encountered Element : Rule and Type : 1
Encountered Element : #text and Type : 3

                                 In XML file root Signature is having only one child that is "Rule", but its showing 3(Three) children 1st -> #text, 2nd -> Rule, and 3rd -> #text. I am thinking its giving 2 #text child because in XML file after <Signature> tag there is newline and after this newline <Rule> tag is coming, so, its assuming newline as a child. But my question is what should I add in my code that it should take only the actual element (In this case only "Rule" not two #text node.). I am not creating the xml file I have to parse the existing xml file, So, I can't change the structure of given xml file.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 1 Comment.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros