XMLAddNode()

Top  Previous  Next

Object: EHL7.QSXML

FileName: EHL7.dll

 

METHOD

 

Name: XMLAddNode()

Parameters:

1.objNode (XML Node Object) the parent node
2.strXML the XML string you wish to add as a child node to the object

Returns: XML Node Object

Description: This method allows you to add nodes quickly or merge two xml documents into one.  The strXML parameter can contain an entire XML structure of it's own, with children, grandchildren, great grandchildren etc and all will be added as a childnode under the parentnode (objNode)

 

See Also: OpenFromString(), GetRootChildren()

 

Example:

Dim myXMLObj As New EHL7.QSXML

Dim strXML As String

Dim ndRT As Object

Dim ndChild As Object

With myXmlObj

.ClearErrors

strXML = "<GOODXML></GOODXML>"

Call .OpenFromString(strXML)

If .IsError Then

  MsgBox .LastError

  .ClearErrors

  Exit Sub

End If

Set ndRT = .GetRootElement()

'ndRT is now an object of type MSXML2.IXMLDOMNode

MsgBox ndRt.XML

'is the same as calling

MsgBox myXMLObj.XML

'Add some child nodes

strXML = "<CHILDNODE></CHILDNODE>"

Call .XMLAddNode(ndRT,strXML)

Call .XMLAddNode(ndRT,strXML)

Call .XMLAddNode(ndRT,strXML)

Call .XMLAddNode(ndRT,strXML)

MsgBox Cstr(.CountChildNodes(ndRT,"CHILDNODE")) & " nodes"

'Now make some grandchildren

Set ndChild = ndRT.ChildNodes(0) 'The first CHILDNODE

strXML = "<GRANDCHILD></GRANDCHILD>"

Call .XMLAddNode(ndChild,strXML)

Call .XMLAddNode(ndChild,strXML)

 

Set ndChild = ndRT.ChildNodes(3) 'The last CHILDNODE

strXML = "<GRANDCHILD></GRANDCHILD>"

Call .XMLAddNode(ndChild,strXML)

Call .XMLAddNode(ndChild,strXML)

MsgBox Cstr(.CountChildNodes(ndChild,"GRANDCHILD")) & " grandchild nodes on CHILDNODE 4"

End With

Set myXMLObj = Nothing