OpenFromString

Top  Previous  Next

Method

OpenFromString(strXML)

Parameters

strXML (String - a valid XML document or snippet)

Returns

Boolean

Example

The OpenFromString() method creates an XML document from a string variable.

 

 

 

Example VBScript Code

 

Private Sub DemoXML()

 

Dim oXML, ndRoot, ndChild

Dim sBuff, i

 

'Create the object

Set oXML = oUTILITIES.NewCommandoXMLObject()

 

'Using the With / End With statements make for easy shortcuts

With oXML

   'Create an XML document 

   sBuff = "<ROOT></ROOT>"

   If Not .OpenFromString(sBuff) Then 

     SMEvent.Raise "ERROR", "XML OpenFromString Failed"

   End If

   Set ndRoot = .GetRootElement()   

   .SetAttribute ndRoot, "DATE", oUTILITIES.VBFormat(Now, "dd mmm yyyy")

   'Add Some Child Nodes

   sBuff = "<CHILD></CHILD>"

   For i = 1 To 10 

        Set ndChild = .XMLAddNode(ndRoot, sBuff)

        .SetAttribute ndChild, "INDEX", i

   Next   

   'save the XML

   If Not .Save(oUTILITIES.Outputfolder & "MyFileName.XML") Then

     SMEvent.Raise "ERROR", "XML Save Failed"

   End IfEnd With

'Clean up the objects

Set ndRoot = Nothing

Set ndChild = Nothing

Set oXML = Nothing

 

End Sub

 

See Also: oUTILITIES.NewCommandoXMLObject()