Hi there,
I'm trying for a while to obtain the XML content of a file without spaces.
I have a XML file with the following content:
<script>
<command>
<createDocument>
<name>MyDocument</name>
<type>Text</type>
</createDocument>
</command>
<command>
<createFile>
<name>MyFile</name>
<type>File</type>
</createFile>
</command>
</script>
It happens that I need to obtain the name and type values from the XML but
I'm getting the content with white spaces. Here is the code I'm trying to
use:
Code: ( text )
void MySAX2Handler::startElement(const XMLCh* const uri,
const XMLCh* const localname,
const XMLCh* const qname,
const Attributes& attrs)
{
outStream.clear();
char* message = XMLString::transcode(localname);
std::cout << "I saw element: "<< message << std::endl;
XMLString::release(&message);
}
void MySAX2Handler::fatalError(const SAXParseException& exception)
{
char* message = XMLString::transcode(exception.getMessage());
std::cout << "Fatal Error: " << message
<< " at line: " << exception.getLineNumber()
<< std::endl;
}
void MySAX2Handler::characters(const XMLCh* const chars, const
unsigned int length)
{
char* message = XMLString::transcode(chars);
std::cout << "Characters: " << message << " Lenght: " << length <<
std::endl;
if (XMLString::compareIString(chars,XMLUni::fgZeroLen String) !=
0) {
outStream << message;
}
XMLString::release(&message);
}
void MySAX2Handler::endElement(const XMLCh* const uri, const XMLCh*
const localname, const XMLCh* const qname)
{
std::cout << "EndElement - OutStream: " << outStream.str() <<
std::endl;
}
But I'm still getting the outStream value from the endElement with white
spaces.
I would really appreciate if you can help me to solve this problem.
Thank you.
San
--
View this message in context:
http://www.nabble.com/Trying-to-get-the-XML-content-without-spaces-with-SAX--SAX2-tp15490873p15490873.html
Sent from the Xerces - C - Users mailing list archive at Nabble.com.