2012/8/2 Elvis Stansvik <elvst...@gmail.com>: > 2012/8/2 mojtaba shahi Senobari <mojtaba.shahi3...@gmail.com>: >> Hi all >> >> I was working with KoXmlReader and at a node ( just include attributes ) i >> try firstChild(). >> >> I except an element, that should be a child of my node, but no result. > > Perhaps what you're looking for is firstChildElement() ? I think in > DOM, a node can by any type of node (element node, attribute node, > text node et.c.), and the first child node happens to be an attribute > node in your case. > > I think firstChildElement will give you the first child element node.
I think I am wrong. At least I'm seeing a difference in behavior in KoXml vs. QDom here. With this input test.xml: <foo> <bar/> </foo> the program #include <QDebug> #include <QFile> #include <QDomDocument> #include <QDomNode> int main (int, char **) { QFile file("test.xml"); QDomDocument doc; doc.setContent(&file); switch (doc.documentElement().firstChild().nodeType()) { case QDomNode::ElementNode: qDebug() << "ElementNode"; break; case QDomNode::AttributeNode: qDebug() << "AttributeNode"; break; case QDomNode::TextNode: qDebug() << "TextNode"; break; default: qDebug() << "Unknown"; break; } return 0; } gives ElementNode as output, while the program #include <KoXmlReader.h> int main (int, char **) { QFile file("test.xml"); KoXmlDocument doc; doc.setContent(&file); switch (doc.documentElement().firstChild().nodeType()) { case KoXmlNode::ElementNode: qDebug() << "ElementNode"; break; case KoXmlNode::TextNode: qDebug() << "TextNode"; break; default: qDebug() << "Unknown"; break; } return 0; } gives TextNode as output. Shouldn't KoXml* and QDom* be functionally equivalent? Elvis > > Elvis > >> >> I checked and found that the result of firstChild is a KoXmlText. >> >> I think in this method (firstChild) programmer has not ignored attributes >> of node. >> >> and this is for method KoXmlReader::nextSibling(). >> >> Am i right and it is a bug or no, i am doing some thing wrong ? >> >> moji >> >> _______________________________________________ >> calligra-devel mailing list >> calligra-devel@kde.org >> https://mail.kde.org/mailman/listinfo/calligra-devel >> _______________________________________________ calligra-devel mailing list calligra-devel@kde.org https://mail.kde.org/mailman/listinfo/calligra-devel