I'm just getting started in XML myself, and it takes some figuring out, but
here are some samples of what I've done so far. The function
"tl_xml_stylemaster" reads the name of an ADT project style master folder
out of the project XML file. The function "tl_xml_getlevs" lists the levels
in the project. The variable filnam represents the name of an XML file.
You need to include a reference in your project to a Microsoft XML parser
(get it from Microsoft if it's not already on your computer). I recently
noticed that Autodesk also provides an XML editing tool, and that may be
better, but I haven't looked into it.
Hope this helps. If you need more info, I suggest the book "XML for Dummies"
and the Microsoft XML online help.
Public Function tl_xml_getstylemaster(filnam as string) As String
Dim msdom As DOMDocument
Dim Masterfile As String
On Error GoTo Handler
Set msdom = CreateObject("MSXML.DOMDocument")
msdom.Load (filnam)
msdom.async = False
tl_xml_getstylemaster =
msdom.selectSingleNode("//Project/Standards/AECStandards/File/Path").Text
GoTo Egress
Handler:
MsgBox Err.number & " " & Err.Description
Err.Clear
Egress:
Set msdom = Nothing
End Function
Public Function tl_xml_getlevs(filnam As String) As Variant
Dim msdom As DOMDocument
Dim levs As IXMLDOMNodeList
Dim lev As IXMLDOMNode
Dim cnt, cnt1 As Integer
On Error GoTo Handler
Set msdom = CreateObject("MSXML.DOMDocument")
With msdom
.Load (filnam)
.async = False
Set levs = .selectSingleNode("Project").selectNodes("Level")
End With
Dim levdat() As String
With levs
ReDim levdat(.Length - 1, 5)
For cnt = 0 To .Length - 1
Set lev = .Item(cnt)
For cnt1 = 0 To lev.Attributes.Length - 1
levdat(cnt, cnt1) = lev.Attributes(cnt1).Text
Next cnt1
Next cnt
End With
tl_xml_getlevs = levdat
GoTo Egress
Handler:
MsgBox Err.number & " " & Err.Description
Err.Clear
Egress:
Set levs = Nothing: Set lev = Nothing
Set msdom = Nothing
End Function
"Rakesh Rao" wrote in message
news:5104610@discussion.autodesk.com...
Hello,
Does anyone have VB sample code to read/write XML files?
I know something about reading XML files bu am not sure how to go about
writing (creating) one except that I know what data I need to represent in
XML.
Any help is appreciated.
Regards
Rakesh