General XMetaL Discussion
elias June 7, 2011 at 9:47 am
Getting nodes subsetJune 7, 2011 at 9:47 amParticipants 2Replies 3Last Activity 11 years, 2 months ago
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.Derek Read June 7, 2011 at 4:40 pm
Reply to: Getting nodes subsetJune 7, 2011 at 4:40 pm
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-walkerelias June 8, 2011 at 3:04 am
Reply to: Getting nodes subsetJune 8, 2011 at 3:04 am
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.
- You must be logged in to reply to this topic.