VB & XML
Posted on 2002-05-24
I am trying to add an xml string in the format "<problem><needHelp>problemId</needHelp></problem>"as well as adding the XML stored in another DOM into One single DOM to process. What I am doing at present is calling the below sub and passing in the element to add onto , the new name and the String or the DOM.xml respectively.
However, the problem I am having is that when I add this onto the DOM the dom treats it as a text node and converts the < into < and > into >
In java I would use importNode is there a MSXML2 equivalent or is there a workaround.
Public Sub addValueElement(ByRef parent As MSXML2.IXMLDOMNode, name As String, value As Variant)
Dim doc As MSXML2.DOMDocument
Dim child As MSXML2.IXMLDOMElement
'get the owner Document of the Node
Set doc = parent.ownerDocument
'create the new Element
Set child = doc.createElement(name)
If value <> "" Then
'give the element a child text node
'containing the value
'append the child node onto the element