KoXmlReader, this is bug or not

Elvis Stansvik elvstone at gmail.com
Thu Aug 2 19:09:47 BST 2012


2012/8/2 Jaime <jtamate at gmail.com>:
> Hi all,
>
>   I think this is again the never ending problem of spaces or not
> spaces while parsing xml.
>   I have not tested your programs, but KoXmlDocument probably will
> behave as QDom if you pass false in the KoXmlDocument constructor.

You're absolutely right. I just tested and it does.

So then it's up to Moji if he want's to use that solution or use
firstChildElement() (which I see was added by Thorsten back in
January).

Thanks,
Elvis

>
> Best Regards.
>
> 2012/8/2 Elvis Stansvik <elvstone at gmail.com>:
>> 2012/8/2 Elvis Stansvik <elvstone at gmail.com>:
>>> 2012/8/2 mojtaba shahi Senobari <mojtaba.shahi3000 at 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 at kde.org
>>>> https://mail.kde.org/mailman/listinfo/calligra-devel
>>>>
>> _______________________________________________
>> calligra-devel mailing list
>> calligra-devel at kde.org
>> https://mail.kde.org/mailman/listinfo/calligra-devel
> _______________________________________________
> calligra-devel mailing list
> calligra-devel at kde.org
> https://mail.kde.org/mailman/listinfo/calligra-devel



More information about the calligra-devel mailing list