For example if I have a xml like this -
<?xml version="1.0" encoding="UTF-8"?>
<tree path="//" message="SUCCESS">
<item restype="0" resname="1myd" size="-" ver="-"
lmd="2014/03/12 02:29:09" thumb="N" attrib_star="0"
attrib_desc="0" share="-" capture_date="0"
save_time="2014/03/12 02:29:09" chk="NA"/>
<item restype="0" resname="Test333" size="-" ver="-"
lmd="2014/03/11 00:53:42" thumb="N" attrib_star="0"
attrib_desc="0" share="-" capture_date="0"
save_time="2014/03/11 00:53:42" chk="NA"/>
</tree>
<?xml version="1.0" encoding="UTF-8"?>
<tree path="//" message="SUCCESS">
<item restype="0" resname="1myd" size="-" ver="-"
lmd="2014/03/12 02:29:09" thumb="N" attrib_star="0"
attrib_desc="0" share="-" capture_date="0"
save_time="2014/03/12 02:29:09" chk="NA"/>
<item restype="0" resname="Test333" size="-" ver="-"
lmd="2014/03/11 00:53:42" thumb="N" attrib_star="0"
attrib_desc="0" share="-" capture_date="0"
save_time="2014/03/11 00:53:42" chk="NA"/>
</tree>
To copy to clipboard, switch view to plain text mode
Now I need the whole node as string like this-
Output:
<item restype="0" resname="Test333" size="-" ver="-" lmd="2014/03/11 00:53:42" thumb="N" attrib_star="0" attrib_desc="0" share="-" capture_date="0" save_time="2014/03/11 00:53:42" chk="NA"/>
Output:
<item restype="0" resname="Test333" size="-" ver="-" lmd="2014/03/11 00:53:42" thumb="N" attrib_star="0" attrib_desc="0" share="-" capture_date="0" save_time="2014/03/11 00:53:42" chk="NA"/>
To copy to clipboard, switch view to plain text mode
What I tried was not giving me this whole thing as text.
void Util::parseXml(void)
{
QFile file("/home/rahul/Desktop/file.xml");
return;
if (!domDoc.setContent(&file))
{
file.close();
return;
}
file.close();
QDomNode node
= domDoc.
elementsByTagName("item").
at(0);
qDebug() << elem.text();
}
void Util::parseXml(void)
{
QDomDocument domDoc("myDoc");
QFile file("/home/rahul/Desktop/file.xml");
if(!file.open(QIODevice::ReadOnly))
return;
if (!domDoc.setContent(&file))
{
file.close();
return;
}
file.close();
QDomNode node = domDoc.elementsByTagName("item").at(0);
QDomElement elem = node.toElement();
qDebug() << elem.text();
}
To copy to clipboard, switch view to plain text mode
Kindly help me with this. Thank you.
Bookmarks