This is an http response that will always contain a single node. I am having issues incorporating the document examples to read the attributes of the entry.
add a break just after the loadxml line
then with the debugger look inside the xmldocumment, you will easily where the nodes your’re searching for are.
Yes, but the author “preference” is a very old approach that leads to over engineered documents.
A more OOP approach is using attributes as atomic properties and node as non atomic properties (array, list, etc)
In any case the original request (really common) can be solved with this extension function:
Public Function nodeText(extends node as XmlNode, subNodeName as String = "") as String
If subNodeName="" Then
If node.FirstChild<>Nil And node.FirstChild IsA XmlTextNode Then Return node.FirstChild.Value
Else
Dim xql As New XmlNodeList
xql=node.Xql(subNodeName+"/text()")
If xql.Length=1 Then
Return xql.Item(0).Value
End If
End If
End Function
[quote]App.nodeText Declaration
The extends modifier cannot be used on a class method
Function nodeText(extends node as XmlNode, subNodeName as String = “”) As String[/quote]
[quote]App.ParseXML, line 4
Type “XmlElement” has no member named “nodeText”
System.DebugLog("IP: " + xml.DocumentElement.nodeText(“IP”))[/quote]
[quote]App.ParseXML, line 4
Type mismatch error. Expected TextLiteral, but got Int32
System.DebugLog("IP: " + xml.DocumentElement.nodeText(“IP”))[/quote]
[quote]App.ParseXML, line 4
Parameter “msg” expects type String, but this is type No Type.
System.DebugLog("IP: " + xml.DocumentElement.nodeText(“IP”))[/quote]
I have also noticed that the .Value of each node is blank.
Scott, all the methods where the first parameter begins with extends must be placed in a module and must be public
Then you have a new method for the object. In this case you have a new method for the XMLNode called nodeText that (as for getAttribute) reply with the text node contents if exists otherwise with an empty string.
Sorry to have not remarked this in the sample code. (I simply noted that it is an extension code)