xml - get number of columns
My XML looks like this:
Code:
<row>
<column name="name">c1</column>
<column name="address">c2</column>
</row>
<row>
<column name="name">c11</column>
<column name="address">c22</column>
</row>
Is there any easy way to get the numbers of columns in a row?
btw: The number of columns is in all rows the same.
Re: xml - get number of columns
I don't know if I understand the problem correctly, but how about this:
Code:
int columncount = 0;
for(QDomElement colelement
= rowelement.
firstChildElement("column");
!colelement.isNull();
colelement = colelement.nextSiblingElement("column")
)
columncount++;
qDebug("Column count is %d", columncount);
Re: xml - get number of columns
Take a look at QtXml module. A few XML examples are shipped with Qt, and there are short pieces of example code in the docs as well: QDomDocument, QDomElement..
Re: xml - get number of columns
int columns = xml_doc.documentElement().firstChild().firstChildE lement().childNodes().count();