| Author |
how to read this value
|
|
| Mike Downey 2005-02-25, 6:37 pm |
| I have this XML file and am trying to get the value of the IR Code how do
i read this?
This is the whole file.
<?xml version="1.0" encoding="utf-8" ?>
<anyType xmlns:q1="http://www.w3.org/2001/XMLSchema" d1p1:type="q1:string"
xmlns:d1p1="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://dev.cikd.com/Wireless/"> Wireless Link Sent - IR Code:
063</anyType>
I am used to looping through nodes like this but there is no nodes that I
can see:
Private Sub Form_Load()
Dim objDoc As MSXML2.DOMDocument40
Dim objNodeList As MSXML2.IXMLDOMNodeList
Dim objNode As MSXML2.IXMLDOMNode
Set objDoc = New MSXML2.DOMDocument30
If objDoc.Load("c:\customerdata.xml") Then
If Not objDoc Is Nothing Then
Set objNodeList =
objDoc.selectNodes("customerdata/customer/firstname")
If Not objNodeList Is Nothing Then
'Loop though each node in the node list
For Each objNode In objNodeList
Debug.Print objNode.Text
Next
End If
End If
End If
End Sub
please help.
Thanks,
Mike
| |
| Derek Harmon 2005-02-27, 4:16 am |
| "Mike Downey" <mdowne@hotmail.com> wrote in message news:ejkbjH3GFHA.2136@TK2MSFTNGP14.phx.gbl...
> trying to get the value of the IR Code how do i read this?
: :
> <?xml version="1.0" encoding="utf-8" ?>
> <anyType xmlns:q1="http://www.w3.org/2001/XMLSchema" d1p1:type="q1:string" xmlns:d1p1="http://www.w3.org/2001/XMLSchema-instance"
> xmlns="http://dev.cikd.com/Wireless/"> Wireless Link Sent - IR Code: 063</anyType>
: :
> Set objNodeList = objDoc.selectNodes("customerdata/customer/firstname")
The XML sample you've shown contains one element named "anyType" but
this XPath expression speaks of "firstname", "customer" and "customerdata",
no surprise that wouldn't find anything.
To match the "anyData" node in your sample you need to set a namespace
and prefix (though it may be the default namespace, you still need to use a
prefix in your XPath expression so you register any arbitrary prefix against
the default namespace URI to do this).
objDoc.setProperty("SelectionLanguage", "XPath") // You may have forgot this, too.
objDoc.setProperty("SelectionNamespaces","xmlns:ns1='http://dev.cikd.com/Wireless/'")
Set objNodeList = objDoc.selectNodes("/ns1:anyType")
You should be able to take the text child node(s) of these anyType elements
and parse out the substring representing the IR code.
Derek Harmon
| |
| Mike Downey 2005-02-28, 6:35 pm |
|
VisualBasic 6 using msxml3.dll
How do I do this?
Here is my code
Dim vartemp As String
Dim objDoc As MSXML2.DOMDocument40
Dim objNode As MSXML2.IXMLDOMNode
Dim mrd As Variant
txtHTML = "<?xml version="1.0" encoding="utf-8" ?>
<anyType xmlns:q1="http://www.w3.org/2001/XMLSchema"
d1p1:type="q1:string"
xmlns:d1p1="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://dev.cikd.com/Wireless/"> Wireless
Link Sent - IR Code: 063</anyType>"
Set objDoc = New MSXML2.DOMDocument30
objDoc.loadXML (txtHTML)
objDoc.selectSingleNode ("anyType")
mrd = objDoc.nodeTypedValue
Why does MRD show up as NULL each time?
| |
| Mike Downey 2005-02-28, 6:35 pm |
| i figured it out ... thanks!
Dim vartemp As String
Dim objDoc As MSXML2.DOMDocument40
Dim objNode As MSXML2.IXMLDOMNode
Dim objNodeList As MSXML2.IXMLDOMNodeList
Dim mrd As Variant
txtHTML = > txtHTML = "<?xml version="1.0" encoding="utf-8" ?>
<anyType xmlns:q1="http://www.w3.org/2001/XMLSchema"
d1p1:type="q1:string"
xmlns:d1p1="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://dev.cikd.com/Wireless/"> Wireless
Link Sent - IR Code: 063</anyType>"
Set objDoc = New MSXML2.DOMDocument30
objDoc.loadXML (txtHTML)
Set objNodeList = objDoc.selectNodes("anyType")
For i = 0 To (objNodeList.length - 1)
Set objNode = objNodeList.nextNode
MsgBox (objNode.Text)
Next
"Mike Downey" <mdowne@hotmail.com> wrote in message
news:%23q2T1LaHFHA.2276@TK2MSFTNGP15.phx.gbl...
>
> VisualBasic 6 using msxml3.dll
>
> How do I do this?
>
> Here is my code
>
> Dim vartemp As String
> Dim objDoc As MSXML2.DOMDocument40
> Dim objNode As MSXML2.IXMLDOMNode
> Dim mrd As Variant
>
> txtHTML = "<?xml version="1.0" encoding="utf-8" ?>
> <anyType xmlns:q1="http://www.w3.org/2001/XMLSchema"
> d1p1:type="q1:string"
> xmlns:d1p1="http://www.w3.org/2001/XMLSchema-instance"
> xmlns="http://dev.cikd.com/Wireless/"> Wireless
> Link Sent - IR Code: 063</anyType>"
>
> Set objDoc = New MSXML2.DOMDocument30
> objDoc.loadXML (txtHTML)
>
> objDoc.selectSingleNode ("anyType")
>
> mrd = objDoc.nodeTypedValue
>
>
> Why does MRD show up as NULL each time?
>
>
>
|
|
|
|
| Copyright 2003 - 2008 forum4designers.com Software forum Computer Hardware reviews |