Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 8th, 2007, 11:52 AM
Authorized User
 
Join Date: Jun 2003
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Kabe
Default xhtml, remove element

can't figure it out to remove in vbscript an element in xhtml

have this:
xhtmlvalue = "<html><body><SPAN id=""intro"">to remove</SPAN><p>rest</p></body></html>"

Set objXMLDoc = CreateObject("Msxml2.DOMDocument.3.0")
objXMLDoc.loadxml(xhtmlvalue)
Set objRoot = objXMLDoc.documentelement
set objExNode = objRoot.selectsinglenode("//SPAN")
objRoot.removeChild(objExNode)

any help?
thx!
kristof
 
Old November 8th, 2007, 11:55 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Its unlikely that the found node is actually a direct child of the root.

objExNode.parent.removeChild(objExNode) might do it (or whatever the parent property is).

/- Sam Judson : Wrox Technical Editor -/
 
Old November 8th, 2007, 12:00 PM
Authorized User
 
Join Date: Jun 2003
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Kabe
Default

u're sure this is right?

kristof
 
Old November 8th, 2007, 12:07 PM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

No - how about you give it a go and see - if its doesn't work then try to think about why not and see if you can work it out.

/- Sam Judson : Wrox Technical Editor -/
 
Old November 8th, 2007, 12:09 PM
Authorized User
 
Join Date: Jun 2003
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Kabe
Default

understand of course ... but indeed, found it with use of 'firstchild' to arrive in the correct xpath position

thx
kristof





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem adding element to the previous element dani1 XSLT 5 September 10th, 2008 01:38 AM
remove duplicate text in an output html element mrame XSLT 1 June 20th, 2008 01:41 AM
remove <div>-element Kabe Classic ASP Professional 0 November 9th, 2007 05:41 AM
adding of element and assigning to one element sushovandatta XSLT 2 November 16th, 2004 07:04 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.