Hi Sanat. Check out for the return types. getNodeName returns a XMLCh* and not a char*. XMLCh* behaves much like a wchar_t* under Windows but is NOT really equal to it. Therefore you should check for the XMLString::transcode functionality given in most of the sample code (e.g. DOMCount: char *name = XMLString::transcode(n->getNodeName());). Look for class XStr or StrX which are doing the transcode transparantly for you but check if these classes may have become obsolete in your distribution.
Regards Frank > -----Original Message----- > From: Sanat Talmaki [mailto:[email protected]] > Sent: Dienstag, 2. Februar 2010 05:49 > To: [email protected] > Subject: help using getNodeType and getNodeName > > Hello, > I am having trouble understanding the getNodeName and > getNodeType functions. > I am trying a simple program just to understand the basics of > xerces. My > code is below. I parse the xml doc and then call a function > NodeDetails. > When I run it, I dont get the output I expected. > I have pasted below the xml file, the code and the output I am > getting........ > If you can guide me a little, I would be very grateful. > > Thank You > > Sanat. > > -------------------------------------------------------------- > -------------------------------------------------------------- > -------------------------------------------------------------- > --------------------------------------------- > The XML file I am using is: > <?xml version="1.0" encoding="utf-8"?> > <catalog> > <book id="bk101"> > <author>Gambardella, Matthew</author> > <title>XML Developer's Guide</title> > <genre>Computer</genre> > <price>44.95</price> > <publish_date>2000-10-01</publish_date> > <description> > An in-depth look at creating applications > with XML. > </description> > </book>...................... > > -------------------------------------------------------------- > --------------------------- > skeleton code is below: > > > DOMDocument* document = parser->getDocument(); > > NodeDetails(document); > > void NodeDetails(DOMNode* node) > { > cout << "Node Type: " > << node->getNodeType() > << endl > << "Node Name: " > << (node->getNodeName()) > << endl; > if(node->hasChildNodes()) > { > cout << "Child Node Type: " > << node->getFirstChild()->getNodeType() > << endl > << "Node Name: " > << (node->getFirstChild()->getNodeName()) > << endl; > } > -------------------------------------------------------------- > --------------------------------------------------------------------- > Output: > > Node Type: 9 > Node Name: 1227DEAC > Child Node Type: 1 > Node Name: 008DB2D4 >
