ljb
Tue Mar 15 09:07:01 CST 2005
"Tarllem" <no@no.no> wrote in message
news:eH%236V5UKFHA.2996@TK2MSFTNGP10.phx.gbl...
> is possible create a XML document in VBS?
>
>
Try this
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/xmconworkingwithxmldocumentparts_attributes.asp
My variation of the above works fine.
Set xmlDoc = CreateObject("Msxml2.DOMDocument")
xmlDoc.appendChild(xmlDoc.createProcessingInstruction("xml",
"version=""1.0"""))
Set rootElement=xmlDoc.createElement("memo")
xmlDoc.appendChild(rootElement)
rootElement.setAttribute "author","Pat Coleman"
Set theElement=xmlDoc.createElement("to")
Set theElementText=xmlDoc.createTextNode("Carole Poland")
rootElement.appendChild(theElement)
theElement.appendChild(theElementText)
Set theElement=xmlDoc.createElement("subject")
Set theElementText=xmlDoc.createTextNode("big layoff coming")
rootElement.appendChild(theElement)
theElement.appendChild(theElementText)
'Dim docFragment As IXMLDOMDocumentFragment
Set docFragment = xmlDoc.createDocumentFragment()
docFragment.appendChild xmlDoc.createElement("node1")
docFragment.appendChild xmlDoc.createtextnode("node1 value")
docFragment.appendChild xmlDoc.createElement("node2")
docFragment.appendChild xmlDoc.createElement("node3")
MsgBox docFragment.xml
xmlDoc.documentElement.appendChild docFragment
MsgBox xmlDoc.xml
xmldoc.save "test1.xml"