ad5xj
25th April 2014, 20:18
I am attempting to parse a web-based reply text stream that has a XML-like structure. It seems to say it is XML 1.0 but not sure how well it complies.
The content is similar to this:
<?xml version="1.0"?>
<RootNAME version="2.0" xmlns="http://www.website.com">
<session>
<session_id>09b0ae90050be03c452ad235a1f2915ad684393c</session_id>
</session>
</RootNAME>
To test, I have captured the reply text to a file I have called returnedtext.xml.
I have attempted to use QXmlQuery in a file I called myquery.xq:
doc("returnedtext.xml")//RootNAME/session/<p>string(text(session_id))</p>
I have tried to use the xmlpatterns utility to test the query. However, the utility does not return an error nor the plaintext in the <session_id> element.
I have also looked at QDomDocument but got nowhere quickly.
XML return sources from this same site do not contain attributes - only unique node names. The QXmlQuery and QXmlPatterns methods do not seem to contain a method to return the plaintext in a node that does not have a named attribute with a value or a xmls attribute.
I am new to XML parsing so any detailed C++ code and/or QXmlQuery help would be appreciated.
Environment:
Qt 5.2.1 on Linux Mint 16
CPU DUAL CORE Athlon 64 5400+
3 Gb Ram 500Gb disk with 300Gb free
The content is similar to this:
<?xml version="1.0"?>
<RootNAME version="2.0" xmlns="http://www.website.com">
<session>
<session_id>09b0ae90050be03c452ad235a1f2915ad684393c</session_id>
</session>
</RootNAME>
To test, I have captured the reply text to a file I have called returnedtext.xml.
I have attempted to use QXmlQuery in a file I called myquery.xq:
doc("returnedtext.xml")//RootNAME/session/<p>string(text(session_id))</p>
I have tried to use the xmlpatterns utility to test the query. However, the utility does not return an error nor the plaintext in the <session_id> element.
I have also looked at QDomDocument but got nowhere quickly.
XML return sources from this same site do not contain attributes - only unique node names. The QXmlQuery and QXmlPatterns methods do not seem to contain a method to return the plaintext in a node that does not have a named attribute with a value or a xmls attribute.
I am new to XML parsing so any detailed C++ code and/or QXmlQuery help would be appreciated.
Environment:
Qt 5.2.1 on Linux Mint 16
CPU DUAL CORE Athlon 64 5400+
3 Gb Ram 500Gb disk with 300Gb free