Reading XML data

Reading XML data

Anonymous
Not applicable
518 Views
3 Replies
Message 1 of 4

Reading XML data

Anonymous
Not applicable
I hope someone can help jump-start me in reading data from ADT XML files. I
would like to simply obtain certain information from the .apj (project data
folders) so I can use it in VBA. I can get the XML document open, but have
no idea what to do after that.

I have MSXML reference in my project and have gotten as far as opening the
XML document, but then have no idea how to get any particular piece of data
out of it. I'm trying to figure it out from books and MS online docs, but
they're telling me way more than I need to know.

Here's what I've got so far:


Option Explicit

Public Sub testxml()
Dim filnam As String
filnam = tl_get_adt_project
tl_xml_getval filnam
End Sub

''This gets the name of the ADT project file for the current active project
from the registry
Public Function tl_get_adt_project() As String
Dim key As RegKey
Dim keystr, keystr1 As String
keystr = "\HKEY_CURRENT_USER\software\Autodesk\autocad\" & _
"R16.2\ACAD-4004:409\recent Project list"
Set key = Registry.RegKeyFromString(keystr)
keystr1 = key.Values("Project1")
tl_get_adt_project = keystr1
End Function


' This opens the file and
Public Sub tl_xml_getval(xmfile As String) As String
Dim msdom As DOMDocument
Dim xx As IXMLDOMNodeList
Dim itm As IXMLDOMNode
Set msdom = CreateObject("MSXML.DOMDocument")
msdom.Load (xmfile)
msdom.async = False

''At this point, I have no idea what to do

Set msdom = Nothing
End Sub
0 Likes
519 Views
3 Replies
Replies (3)
Message 2 of 4

Mikko
Advocate
Advocate
Private Sub CommandButton1_Click()
Call This("c:\temp\stocklist.xml")
End Sub

Public Sub This(xmfile As String)
Dim msdom As DOMDocument
Dim xx As IXMLDOMNodeList
Dim itm As IXMLDOMNode
Set msdom = CreateObject("MSXML.DOMDocument")
msdom.Load (xmfile)
msdom.async = False
Set itm = msdom.documentElement.childNodes.Item(1)
MsgBox itm.xml
Set msdom = Nothing
End Sub

Attached is a stocklist.zip file which is the xml file I used.
0 Likes
Message 3 of 4

Anonymous
Not applicable
The attached AU document covers most of this.

-Chris

"Tony Burba" wrote in message
news:5068226@discussion.autodesk.com...
I hope someone can help jump-start me in reading data from ADT XML files. I
would like to simply obtain certain information from the .apj (project data
folders) so I can use it in VBA. I can get the XML document open, but have
no idea what to do after that.

I have MSXML reference in my project and have gotten as far as opening the
XML document, but then have no idea how to get any particular piece of data
out of it. I'm trying to figure it out from books and MS online docs, but
they're telling me way more than I need to know.

Here's what I've got so far:


Option Explicit

Public Sub testxml()
Dim filnam As String
filnam = tl_get_adt_project
tl_xml_getval filnam
End Sub

''This gets the name of the ADT project file for the current active project
from the registry
Public Function tl_get_adt_project() As String
Dim key As RegKey
Dim keystr, keystr1 As String
keystr = "\HKEY_CURRENT_USER\software\Autodesk\autocad\" & _
"R16.2\ACAD-4004:409\recent Project list"
Set key = Registry.RegKeyFromString(keystr)
keystr1 = key.Values("Project1")
tl_get_adt_project = keystr1
End Function


' This opens the file and
Public Sub tl_xml_getval(xmfile As String) As String
Dim msdom As DOMDocument
Dim xx As IXMLDOMNodeList
Dim itm As IXMLDOMNode
Set msdom = CreateObject("MSXML.DOMDocument")
msdom.Load (xmfile)
msdom.async = False

''At this point, I have no idea what to do

Set msdom = Nothing
End Sub
0 Likes
Message 4 of 4

Anonymous
Not applicable
Thanks to both of you. Exactly what I needed.


"Tony Burba" wrote in message
news:5068226@discussion.autodesk.com...
I hope someone can help jump-start me in reading data from ADT XML files. I
would like to simply obtain certain information from the .apj (project data
folders) so I can use it in VBA. I can get the XML document open, but have
no idea what to do after that.

I have MSXML reference in my project and have gotten as far as opening the
XML document, but then have no idea how to get any particular piece of data
out of it. I'm trying to figure it out from books and MS online docs, but
they're telling me way more than I need to know.

Here's what I've got so far:


Option Explicit

Public Sub testxml()
Dim filnam As String
filnam = tl_get_adt_project
tl_xml_getval filnam
End Sub

''This gets the name of the ADT project file for the current active project
from the registry
Public Function tl_get_adt_project() As String
Dim key As RegKey
Dim keystr, keystr1 As String
keystr = "\HKEY_CURRENT_USER\software\Autodesk\autocad\" & _
"R16.2\ACAD-4004:409\recent Project list"
Set key = Registry.RegKeyFromString(keystr)
keystr1 = key.Values("Project1")
tl_get_adt_project = keystr1
End Function


' This opens the file and
Public Sub tl_xml_getval(xmfile As String) As String
Dim msdom As DOMDocument
Dim xx As IXMLDOMNodeList
Dim itm As IXMLDOMNode
Set msdom = CreateObject("MSXML.DOMDocument")
msdom.Load (xmfile)
msdom.async = False

''At this point, I have no idea what to do

Set msdom = Nothing
End Sub
0 Likes