bleze
3rd January 2013, 09:57
I have a XMLDocument which I parse. At certain points I wish to extract elements/nodes as fragments of XML (QString or UTF-8 encoded QByteArray).
toDocument and toDocumentFragment returns nothing.
I can do this with XPath but this is not what I want. What am I missing? How do I achieve this in Qt?
Simplified code:
QDomDocument doc;
if (doc.setContent(data))
{
QDomElement elementEnvelope = doc.firstChildElement();
QDomElement elementBody = elementEnvelope.firstChildElement();
QDomElement elementMethod = elementBody.firstChildElement();
QDomElement elementParameter = elementMethod.firstChildElement("blah");
}
It's the elementParameter and everything from that point, I wish to extract as XML.
Thanks in advance!
toDocument and toDocumentFragment returns nothing.
I can do this with XPath but this is not what I want. What am I missing? How do I achieve this in Qt?
Simplified code:
QDomDocument doc;
if (doc.setContent(data))
{
QDomElement elementEnvelope = doc.firstChildElement();
QDomElement elementBody = elementEnvelope.firstChildElement();
QDomElement elementMethod = elementBody.firstChildElement();
QDomElement elementParameter = elementMethod.firstChildElement("blah");
}
It's the elementParameter and everything from that point, I wish to extract as XML.
Thanks in advance!