Pages: 1
Print
Author Topic: Getting nodes subset  (Read 2439 times)
elias
Member

Posts: 13


« on: June 07, 2011, 03:47:46 AM »

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. 
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2570



WWW
« Reply #1 on: June 07, 2011, 10:40:36 AM »

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
Logged
elias
Member

Posts: 13


« Reply #2 on: June 07, 2011, 09:04:59 PM »

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.
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2570



WWW
« Reply #3 on: June 08, 2011, 01:46:51 AM »

Sounds like you need these:
Range.SelectBeforeNode()
Range.SelectAfterNode()
Logged
Pages: 1
Print
Jump to: