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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting elements into an existing xml doc 1

Status
Not open for further replies.

lazytrucker

Programmer
Aug 4, 2004
39
GB
Trying to use asp to add to an xml doc on the fly.

Method:

set elementchild=objxml.documentelement.childnodes.Item(i).childnodes(0).createelement("ElementName")

An error is returned object doesnt support this method.

Is there a way of inserting data in to an xml document using asp on the fly???

Any ideas appreciated.

Cheers Lazytrucker.
 
When you create nodes they are not inherently bound to the DOM tree of the document. The CreateElement method is a method of the document and allow you to create an unbound element. At that point you would then use something like:
InsertBefore(newNode,referenceNode) or
ReplaceChild(newNode,NodeToReplace) or
AppendChild(newNode)

So to achieve what you were looking at doing the code would be something like:
Code:
Dim elementChild
Set elementChild = objxml.CreateElement("ElementName")
objxml.documentelement.childnodes.Item(i).childnodes(0).AppendChild elementChild

Not to sure about the last line there, but it is pasted from yours so it should be correct.

-T

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
Need an expensive ASP developer in the North Carolina area? Feel free to let me know.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top