PDA

View Full Version : special characters in xml



khcbabu
6th November 2008, 09:44
how can I read special characters from xml. any sample code will help me much,,, thanks in advance.
my xml structure is like--

<?xml version="1.0" encoding="UTF-8"?>
<settings>
<english>
<one>.,?!1@'-_():;&/%*#+<=>¡¿</one>
<two>abc2äåæà áâãç</two>
<three>def3éèëêð</three>
</english>
<bangla>
<one>"2"</one>
</bangla>
</settings>

aamer4yu
6th November 2008, 10:05
characters are characters,, right ?
What have you tried to read the xml ?
QDomElement , QDomNode will be useful

khcbabu
6th November 2008, 10:53
QDomDocument doc;
doc.setContent(&file);
QDomElement root = doc.documentElement();
QDomNode n = root.firstChild();

while( !n.isNull() )
{
QDomElement e = n.toElement();
if( !e.isNull() )
{
if( e.tagName() == "english" )
{
QDomElement sr =e.firstChildElement("two");
qDebug()<<sr.text();
}
}
n = n.nextSibling();
}

I tried using Qdom, but it works only if there is no special character,, Am I doing something wrong..

jacek
6th November 2008, 23:10
What does "works" mean in this case exactly? Could you post that example XML file as an attachment?