Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to embed one xmldom object to a node of another xmldom objec 1

Status
Not open for further replies.

henryz

Programmer
Oct 3, 2001
33
0
0
AU
Hello everyone,

I have some problem in loading an xmldom object to another node of an xmldom
object. I can load the html
content into an xmldom object, such as HTMLDOM. But I am not sure how
to append the HTMLDOM to one specific node of my original xmldom object. My
code is something like the following:

'my original xmlDom object
Set xmldoc = Server.CreateObject("Microsoft.XMLDOM")

'htmlDom to store html content
Set htmlDom = Server.CreateObject("Microsoft.XMLDOM")

HTMLString = '<snippet>' + HTMLString + '</snippet>';
HTMLDOM.loadXML(HTMLString);

' Build the XML document here
If (xmldoc.childNodes.length = 0) Then
Set root = xmldoc.createNode(&quot;element&quot;, &quot;report&quot;, &quot;&quot;)
xmldoc.appendChild (root)

Set rootnode = xmldoc.createNode(&quot;element&quot;, &quot;row&quot;, &quot;&quot;)
root.appendChild(rootnode)

'column node
Set colNode = xmldoc.createNode(&quot;element&quot;, &quot;column&quot;, &quot;&quot;)
rootnode.appendChild(colNode)

Set innernode = xmldoc.createNode(&quot;element&quot;,&quot;caption&quot;,&quot;&quot;)
innernode.Text =&quot;ID&quot;
colNode.appendChild(innernode)

Set innernode = xmldoc.createNode(&quot;element&quot;,&quot;value&quot;,&quot;&quot;)
??? ???
'Here I want to append htmlDom to the value node, but I am not sure how
to do it. I have a play with Chris Bayes's domtodom.js code
( but have no idea how
to implement the javascript functions into my case here. Some suggestions
here will be most appreciated..

Thanks in advance

Henry
 
nodeToAppendto.appendChild Domdocument.firstchild

or more specific to you:

innernode.appendchild htmlDom.firstchild

You can't append a document type node directly, but if you use domdocument.firstchild to select the rootnode you can then append it to the desired node in your other document.

Hope that helps.

Watch out for html formatting problems and namespace confusion though.... &quot;Lets integrate!&quot;
If it doesn't work it's not my fault.
 
Dear DrHeadgear,

Thank you so much for your reply. I try your way, but I had an runtime
exception, it says as following:


Microsoft VBScript runtime error '800a0005'

Invalid procedure call or argument: 'innernode.appendChild'

Some more suggestions will be great

Thanks a lot for your help

Henry






 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top