Results 1 to 3 of 3

Thread: traverse a xml tree

  1. #1
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default traverse a xml tree

    hello,
    I just a newbie and I'm working around xml;
    I have a xmlTree but now I need to visit the tree and sometimes I need to change some node attributes; eventually I must to put it into a string (with '<' '>' too)
    Do everyone give me any help? (this is c# but the keyword will be similar)

    THanks

    Qt Code:
    1. XmlNode root = Xml_doc.FirstChild;
    2. ...........................................
    To copy to clipboard, switch view to plain text mode 
    Regards

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: traverse a xml tree

    Take a look at QDomDocument and friends if you use Qt or libxml if you don't.

  3. #3
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: traverse a xml tree

    hello and thanks for reply. I dont' use c++ but C#. I tried with this:
    Qt Code:
    1. XmlNode n = Xml_doc.FirstChild;
    2. while (n != null) {
    3. XmlElement e = (XmlElement)n; //conversion
    4. if (e != null) {
    5. Console.WriteLine(e.Name);
    6. }
    7. if (n.NextSibling == null) n = n.FirstChild; //1
    8. else n = n.NextSibling; //2
    9. }
    To copy to clipboard, switch view to plain text mode 
    I isert //1 and //2 because if there isn't brothers Nextsibling return me a null and I'll exit the loop; this seem works but but when I meet a nodeText, conversion generate an exception and however nodeText.nextSibling gets me null;
    ANy hints to improve it, please?
    Regards

Similar Threads

  1. Drag from tree widget
    By EricF in forum Qt Programming
    Replies: 9
    Last Post: 17th December 2007, 23:09
  2. Display a file from Directory tree to show in QTextEdit
    By vvdounai in forum Qt Programming
    Replies: 1
    Last Post: 13th November 2007, 13:43
  3. Replies: 3
    Last Post: 19th April 2007, 11:42
  4. Optimizing filterAcceptsRow() to filter a tree
    By vfernandez in forum Qt Programming
    Replies: 1
    Last Post: 4th January 2007, 12:50
  5. traversing tree using mouse clicks
    By krishna.bv in forum Qt Programming
    Replies: 3
    Last Post: 22nd December 2006, 09:15

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.