Jump to content

XMLDOM and Namespace


ChrisL
 Share

Recommended Posts

I don't understand why I can't read some XML, the example below shows the problem.

_Test() the XML contains xmlns="http://ns.adobe.com/air/framework/update/description/2.5" and will not read the versionNumber

_TestNoNameSpace() has the namespace removed and works fine.

Anyone know why or how I can get this working please?

 

 
#include "_XMLDomWrapper.au3"

MsgBox(0,"",_Test())

MsgBox(0,"",_TestNoNamespace())


Func _Test()

Local $Str = '<update xmlns="http://ns.adobe.com/air/framework/update/description/2.5"><versionNumber>7.0.215</versionNumber></update>'
_XMLLoadXML($str)
$ret = _XMLGetFirstValue("/update/versionNumber")
Return $ret

EndFunc

Func _TestNoNamespace()

Local $Str = '<update><versionNumber>7.0.215</versionNumber></update>'
_XMLLoadXML($str)
$ret = _XMLGetFirstValue("/update/versionNumber")
Return $ret

EndFunc



Func _XMLGetFirstValue($node)

Local $ret_val

$ret_val = _XMLGetValue($node)
If IsArray($ret_val) Then
Return ($ret_val[1])
Else
Return SetError(1,3,0)
EndIf

EndFunc
Link to comment
Share on other sites

You'd probably have to dig into the UDF function to figure it out, but this works:

Local $Str = '<update xmlns="http://ns.adobe.com/air/framework/update/description/2.5"><versionNumber>7.0.215</versionNumber></update>'
$oXML = ObjCreate("Microsoft.XMLDOM")
$oXML.loadXML($Str)
$oNode=$oXML.SelectSingleNode('/update/versionNumber')
ConsoleWrite($oNode.text & @CRLF)

output:

7.0.215

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...