Results 1 to 2 of 2

Thread: childNodes return unexpected nodes

  1. #1
    Join Date
    Jan 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default childNodes return unexpected nodes

    Hi all,

    I have some problems related to QDomNodeList QDomNode::childNodes () const
    For example, I have xml content as the following:
    Qt Code:
    1. <?xml version='1.0' encoding='utf-8'?>
    2. <xliff xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 &#xa; &#xa;xliff-core-1.2-transitional.xsd" >
    3. <file original="String" product-name="String" category="String" build-num="String" target-language="en-us" tool="manual" datatype="plaintext" source-language="en-us" xml:space="default" product-version="String" date="2001-12-17T09:30:47-05:00" ts="String" >
    4. <body>
    5. <group merged-trans="yes" >
    6. <trans-unit id="_1_ski_374" approved="no" >
    7. <source>a contact-email</source>
    8. <target equiv-trans="no" state="needs-translation" >%d ទំនាក់ទំនង</target>
    9. </trans-unit>
    10. <trans-unit id="_1_ski_383" approved="no" >
    11. <source>%d contact-emails.</source>
    12. <target equiv-trans="no" state="needs-translation" >%d contact-emails.sdf</target>
    13. </trans-unit>
    14. </group>
    15. </body>
    16. </file>
    17. </xliff>
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. fileNodes = []
    2. fileNodes = xliff.xlifffile.document.firstChildElement(xliff.xlifffile.rootNode).childNodes()
    3. for k in range(fileNodes.count()):
    4. if fileNodes. at(k).nodeName() == 'file':
    5. _units = fileNodes.at(k).firstChildElement(xliff.xlifffile.bodyNode).childNodes()
    6. for i in range(_units.count()):
    7. print i, _units.at(i).nodeName()
    To copy to clipboard, switch view to plain text mode 

    Output:
    0 #text
    1 group
    2 #text

    In my code, I want to get direct child nodes of <body>, and my expected output should be:
    0 group

    I was wondering where is the #text come from?

    Thanks for you help,
    Da

  2. #2
    Join Date
    Jun 2011
    Posts
    1
    Qt products
    Qt3
    Platforms
    MacOS X

    Default Re: childNodes return unexpected nodes

    are you sure there are no comments in between, because the call reads the comment as a child too!

Similar Threads

  1. Simple way to expand all nodes on a QTreeView?
    By cboles in forum Qt Programming
    Replies: 10
    Last Post: 12th April 2014, 16:54
  2. Unexpected build errors in a Qt project
    By prykHetQuo in forum Qt Programming
    Replies: 2
    Last Post: 24th January 2010, 21:33
  3. QTabWidget->setCornerWidget() unexpected resize.
    By hickscorp in forum Qt Programming
    Replies: 7
    Last Post: 20th December 2006, 14:12
  4. QDomDocument - closed nodes?
    By naresh in forum Qt Programming
    Replies: 2
    Last Post: 19th April 2006, 08:10
  5. [QT4] QTreeView and expandable nodes
    By KShots in forum Qt Programming
    Replies: 3
    Last Post: 17th March 2006, 16:52

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.