PDA

View Full Version : QtXml can't properly resolve xml with char "&" in it



vertusd
1st June 2011, 10:08
<program>
<id>1306917122529</id>
<starttime></starttime>
<endtime></endtime>
<layout><slide fileURL="E:/123&.jpg"/></layout>
<title><![CDATA[1080*1920-ff]]></title>
</program>


dom = QDomDocument()
dom.setContent(xml)
root=dom.documentElement()
p_nodeList = dom.childNodes()
i=0
while i<p_nodeList.count():
nodeList=p_nodeList.at(i).childNodes()
print nodeList.count()
i=i+1
i used above code to print the counts of the children of a program node, For xml with "&" in it ,output is 4, but if i delete "&", output is 5,so why this happen?

sry for my english and thx in advance

arturo182
1st June 2011, 10:26
Using ampersand in XML attributes is not allowed, see http://www.w3.org/TR/xhtml1/#C_12
You should write "&amp;"