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>
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:
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.
Nei
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 >
</command><name>MyDocumen t</name>
<type>Text</type>
</createDocument><type>Text</type>
<command>
</script><createFile>
</command><name>MyFile</name>
<type>File</type>
</createFile><type>File</type>
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:
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::fgZeroLenString) != 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;
}
I would really appreciate if you can help me to solve this problem.
Thank you.
Nei
Comment