Xerces-c++ sample: encoding and number of elements



ALL,


I am trying to follow the Xerces-C++ example of "CreateDOMDocument". Here is my code:



myParser::myParser()
{
m_impl = DOMImplementationRegistry::getDOMImplementation( X( "Core" ) );
if( m_impl )
{
try
{
m_doc = m_impl->createDocument( X( "http:://www.w3.org/2001/XMLSchema-instance" ), X( "my_root_node" ), 0 );
m_root = m_doc->getDocumentElement();
printf( "In constructor: Root element is %d, document size is %d", m_root, m_doc->getElementsByTagName( X( "" ) )->getLength() );
}
}
}


Now, here is what my questions are:



  1. How do I identify the encoding of the document and the xml version? Is it the third parameter to createDocument() function?


I'm talking about the line:



  1. For some reason, the second value that is printed is 0 even though the m_root pointer has a valid value. I would think that if that code threw an exception the m_root pointer would be NULL...


No comments:

Post a Comment