Reputation: 133
I am back to asp with XML manupulation. Initial file:
<?xml version="1.0" ?>
<root>
<sport/>
</root>
this is my function
Public Function DefinitFunction( x,z)
Dim text
Dim Root
Dim NodeList
text = "<Definition>" ---<x> </x> <z> </z> --</Definition> "
text = text & "<x><![CDATA["&x&"]]> </x>"
text = text & "<z> </z>"
text = text & "</Definition>"
Set Root = objDoc.documentElement
Set NodeList = Root.getElementsByTagName("sport")
NodeList.appendChild text
objDoc.Save strFile
end function
' Private strFile, objDoc are class object
I want to modify the all thing dynamically. So I have a function :
DefinitFunction(x,z)
that will concatenate a string and append <Definition> ---<x> </x> <z> </z> --</Definition>
in my file right after the Node <sport>
at the end this should be my result:
<?xml version="1.0" ?>
<root>
<sport>
<Definition>
---<x> </x> <z> </z> --
</Definition>
</sport>
</root>
This is not working. Is there any better way of accomplishing this?
Upvotes: 2
Views: 2966
Reputation: 196002
You cannot append text directly .. you need to convert it to XML node first..
Set newXML = CreateObject("Microsoft.XMLDOM")
newXML.async = False
newXML.loadXML( "<root>" & text & "</root>")
NodeList.appendChild( newXML.documentElement.selectSingleNode("/Definition"))
Upvotes: 2