Results 1 to 2 of 2

Thread: Work with QXmlResultItems

  1. #1
    Join Date
    Dec 2008
    Posts
    5
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Work with QXmlResultItems

    Hi,

    is it possible to select an element from an XML file with XPath, check its contents for certain criteria and then select one of its siblings?

    Qt Code:
    1. <List>
    2. <Item>
    3. <Data>
    4. <Hierarchy>Item</Hierarchy>
    5. <ShortName>MyItem</ShortName>
    6. <Name>ReallyMyItem</Name>
    7. </Data>
    8. </Item>
    9. <Item>
    10. <Data>
    11. <Hierarchy>SubItem</Hierarchy>
    12. <ShortName>MySubItem</ShortName>
    13. <Name>ReallyMySubItem</Name>
    14. </Data>
    15. </Item>
    16. </List>
    To copy to clipboard, switch view to plain text mode 
    So I want to get the name of every item that is an "Item", but not of "SubItem"s.

    I tried to fetch the whole "Data" and try to get out the info but failed to get the query for the sub part valid, so I abandoned that idea.
    Now I am fetching the "Hierarchy" into a QXmlResultItems element. Then I run over it in a loop and find all "Item"s. But what then? Can I access its siblings from the resulting QXmlItem by any chance?

    Or is my attempt wrong in the first place? All this XML stuff is kind of hard to grasp for me.

    Regards

  2. #2
    Join Date
    Dec 2008
    Posts
    5
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Work with QXmlResultItems

    Hi,

    now I solved it in a for me unexpectedly easy way. XPath can do what I want and I solved it like this now.
    Qt Code:
    1. /List/Item/Data[Hierarchy="Item"]/Name
    To copy to clipboard, switch view to plain text mode 
    This way, I get all names from only those data items matching "Item".

    Regards

Similar Threads

  1. Replies: 3
    Last Post: 9th October 2012, 03:12
  2. Replies: 0
    Last Post: 12th July 2011, 09:20
  3. Replies: 2
    Last Post: 13th December 2009, 21:27
  4. QXmlResultItems wierd behavior
    By ixSci in forum Qt Programming
    Replies: 0
    Last Post: 21st August 2009, 13:23
  5. Replies: 3
    Last Post: 15th January 2008, 13:11

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.