|
-
Jun 15th, 2001, 09:57 AM
#1
Thread Starter
New Member
Question on XML DOM object
Does anyone know how I can parse the strings in the quote marks from the following code in XML?
<Cube ID="cls=clsCubeDataOptionChain;basecode=BVSN"/>
<Section ID="" Filters="">
I'm a summer intern with a hefty assignment!!!
-
Jun 15th, 2001, 10:04 AM
#2
Code:
Dim xmlDoc As MSXML.DOMDocument
Set xmlDoc = New MSXML.DOMDocument
xmlDoc.async = False
xmlDoc.load "c:\myxml.xml"
now lets say your xml doc looks like this
Code:
<test>
<Cube ID="cls=clsCubeDataOptionChain;basecode=BVSN"/>
</test>
to get the ID attribute
Code:
Dim myid as string
myid = xmlDoc.selectSingleNode("test/Cube/@ID")
-
Jun 15th, 2001, 10:28 AM
#3
Fanatic Member
OR............
Code:
Dim oXMLdoc As MSXML2.DOMDocument
Dim oElement As MSXML2.IXMLDOMElement
Dim oAttrib As MSXML2.IXMLDOMAttribute
Dim strXML As String
Dim strData As String
Dim sSplit() As String
Set oXMLdoc = New MSXML2.DOMDocument
strXML = "<Data><Cube ID='cls=clsCubeDataOptionChain;basecode=BVSN'/>" & _
"<Section ID='' Filters=''/></Data>"
oXMLdoc.loadXML strXML
Set oElement = oXMLdoc.selectSingleNode("Data/Cube")
If Not oElement.Attributes Is Nothing Then
For Each oAttrib In oElement.Attributes
If oAttrib.Name = "ID" Then
strData = oAttrib.Text
sSplit = Split(strData, ";")
If InStr(1, sSplit(0), "cls") Then
Debug.Print Mid(sSplit(0), 5)
End If
If InStr(1, sSplit(1), "basecode") Then
Debug.Print Mid(sSplit(1), 10)
End If
End If
Next oAttrib
End If
-
Jun 15th, 2001, 01:42 PM
#4
Thread Starter
New Member
Thanks guys
I was able to use your guidance. It worked great. Now, the only thing I'm still trying to figure out is how to edit the text of an attribute.
For instance:
<ft>
<Cube ID="cls=clsCubeDataOptionChain;basecode=BVSN"/>
Say I wanted to get the text from a text box and change "BVSN" to the new text from the user. Which XML method does this the best?
I'm a summer intern with a hefty assignment!!!
-
Jun 15th, 2001, 01:50 PM
#5
Code:
xmlDoc.selectSingleNode("test/Cube/@ID").text = "cls=clsCubeDataOptionChain;basecode=" & Text1.Text
xmlDoc.Save
Last edited by Cander; Jun 15th, 2001 at 01:54 PM.
-
Jun 15th, 2001, 01:56 PM
#6
Might I also make thisw suggestion. Change that Cube element to something like this if you can
Code:
<Cube ID="" cls="clsCubeDataOptionChain" basecode="BVSN"/>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|