[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

MSXML3: Getting the new node object after .replaceChil

Subject: MSXML3: Getting the new node object after .replaceChild
From: "Joel P Thornton" <joelt@xxxxxxxxxxxxx>
Date: Fri, 13 Apr 2001 11:27:00 -0700
vbscript replacechild
I have a question relating specifically to using MSXML3, under VBScript
(ASP).

What I want to do is this: replace a given node with a new node, and then do
something with that new node.  However, I am having a problem here, because
I can't find a way to (elegantly) use that new node after I execute a
replaceChild() on the parent node.  replaceChild() returns the *old* node,
but I need to use the *new* node. And after I have added the new node to the
parent, that node object gets cleared out, so I can't use it anymore.

The only way I'm finding to accomplish this is to first do replaceChild(),
then use selectSingleNode() to find the newly added node of the parent in
question, and work with that.  This is really a workaround, and I'm
wondering if there is a better way to do this, so I can just USE the new
node after executing replaceChild().

Here's the code that won't work as I want it to:

...
Set xmlDocNew = getContentXML("1")
nodeToReplace.parentNode.replaceChild xmlDocNew.documentElement,
nodeToReplace

** at this point, nodeNew is just an empty XML document, its contents being
moved into parentNode's kids. **
...



Here's the workaround I am using but want to improve upon:

...
Set xmlDocNew = getContentXML("1")
Set nodeParent = nodeToReplace.parentNode
nodeParent.replaceChild xmlDocNew.documentElement, nodeToReplace
Set nodeDesired =
nodeParent.selectSingleNode("ContentNode[@content_id='1']")
...

As you can see this is really not ideal ;)  Aside from being a hack job, it
requires I know how to identify the node in advance
("ContentNode[@content_id='1']"), which is just more of a hack as far as I
can see.


Any suggestions most appreciated!!

joel


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.