General XMetaL Discussion

  • elias

    Getting nodes subset

    Participants 2
    Replies 3
    Last Activity 11 years, 2 months ago

    Hello!
    I use Xmetal Author 6.0 and C++ within Microsoft Visual Studio 2003. How can I get the subset of XML nodes between two nodes (including them)?
    Should I use Range object for that?
    I need to move the subset of nodes to another newly created node. 

    Reply

    Derek Read

    Reply to: Getting nodes subset

    You could use Range or you could probably use DOM calls. If you use Range you would likely end up using GotoNext() or MoveToElement() or you might use ExtendTo() or possibly something else. Ranges can be easier to understand.

    If you are using DOM calls you could try nextSibling.

    I guess which you use depends on whether you need to grab the whole mess of nodes at once or whether you need to select the entire thing to do something with it (surround it with another element for example). In that case it might be easier, or even necessary, to use Range.

    For a DOM example you may wish to view the sample code in this Programmers Guide topic:
    http://na.justsystems.com/webhelp/en/xmetaldeveloper/pg/6.0/pg.html#Node%20example:%20A%20simple%20tree-walker

    Reply

    elias

    Reply to: Getting nodes subset

    I need to get the subset of nodes between 2 text nodes (the latter can be positioned at different hierarchy level) and add the to the new node, but I can't find methods which serve as setters for Range boundaries. I mean something like SetBeginBefore(startNode), SetEndAfter(endNode). As far as I remember such methods present in another XML editor (Arbortext Editor).
    And which method should be called for embedding collected nodes into the new node after Range preparation?
    I noticed that Range methods names looked very similar and documentation described it shortly, so Range usage is not intuitive for newbies. I think that documentation should contain not only simple examples, but also the results of the code execution (and pictures) in order to compare similar methods and match the difference.

    Reply

    Derek Read

    Reply to: Getting nodes subset

    Sounds like you need these:
    Range.SelectBeforeNode()
    Range.SelectAfterNode()

    Reply

  • You must be logged in to reply to this topic.

Lost Your Password?

Products
Downloads
Support