Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jan 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    tcl tDOM tree traversal

    Hi all, I'm pretty new to tcl and tDOM both and I sure hope this is the right forum.

    Basically I'm parsing an XML file in tDOM and extracting the data I need. However, in the XML files I'm parsing the depth of the items I'm looking for varies, I know the names of the elements I'm looking for, and it will be the same element name throughout, but the depth will vary.

    IE.

    Parent node item can have an infinite amount of children nodes item, and I need the data out of each one.

    I was thinking of some kind of recursive depth first search but I don't even know if this can be accomplished with tDOM.

    Any help is appreciated.

  • #2
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by Caboose57 View Post
    Hi all, I'm pretty new to tcl and tDOM both and I sure hope this is the right forum.

    Basically I'm parsing an XML file in tDOM and extracting the data I need. However, in the XML files I'm parsing the depth of the items I'm looking for varies, I know the names of the elements I'm looking for, and it will be the same element name throughout, but the depth will vary.

    IE.

    Parent node item can have an infinite amount of children nodes item, and I need the data out of each one.

    I was thinking of some kind of recursive depth first search but I don't even know if this can be accomplished with tDOM.

    Any help is appreciated.
    try to use xpath

    http://wiki.tcl.tk/1948

    something like '*//yournode' could fetch all nodes with name 'yournode', depth doesn't matter.

    best regards


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •