PDA

View Full Version : QXmlStreamReader



sophister
15th June 2009, 17:18
Hello, I use the following xml file to store my data in the application. But when I use QXmlStreamReader to read it into the application, it can only read the first Dish(outer label)
The following is my data.xml

<?xml version="1.0" encoding="UTF-8"?>
<dish>
<score>60</score>
<name>11</name>
<family>1</family>
<season>春</season>
<source>w</source>
<way>wwww</way>
<func>ww</func>
<remark>ww</remark>
</dish>
<dish>
<score>60</score>
<name>12</name>
<family>1</family>
<season>冬</season>
<source>qq</source>
<way>qq</way>
<func>qq</func>
<remark>qq</remark>
</dish>
<dish>
<score>60</score>
<name>2</name>
<family>2</family>
<season>秋</season>
<source>ee</source>
<way>e</way>
<func>e</func>
<remark>e</remark>
</dish>

Do I use the wrong formats to stroe data in an xml file.
Thanks in advance!!

Lykurg
15th June 2009, 17:39
If I remember right you need a single root element:

<?xml version="1.0" encoding="UTF-8"?>
<dishes>
<dish>...</dish>
<dish>...</dish>
<dish>...</dish>
</dishes>

spirit
15th June 2009, 17:47
@Lykurg yes, you remember right (as usual :)).
@sophister, try to open your xml file with browser and you'll see an error.

sophister
15th June 2009, 17:49
Yes, it doesn't open the xml file but an error.
Thank you both!!

sophister
15th June 2009, 17:52
Thanks very much!!

mukundansree
24th August 2011, 09:10
Hello, I use the following xml file to store my data in the application. But when I use QXmlStreamReader to read it into the application, it can only read the first Dish(outer label)
The following is my data.xml

<?xml version="1.0" encoding="UTF-8"?>
<dish>
<score>60</score>
<name>11</name>
<family>1</family>
<season>春</season>
<source>w</source>
<way>wwww</way>
<func>ww</func>
<remark>ww</remark>
</dish>
<dish>
<score>60</score>
<name>12</name>
<family>1</family>
<season>冬</season>
<source>qq</source>
<way>qq</way>
<func>qq</func>
<remark>qq</remark>
</dish>
<dish>
<score>60</score>
<name>2</name>
<family>2</family>
<season>秋</season>
<source>ee</source>
<way>e</way>
<func>e</func>
<remark>e</remark>
</dish>

Do I use the wrong formats to stroe data in an xml file.
Thanks in advance!!

can u tell me how you used XmlReader to take value of name ,family, season

marcvanriet
24th August 2011, 18:31
Maybe you can show us your code ?

If you just use readNext() of QXmlStreamReader, then you should encounter all the entries, of all dishes.

Regards,
Marc