Jump to content
Sign in to follow this  
ChrisL

XMLDOM and Namespace

Recommended Posts

ChrisL

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

Share this post


Link to post
Share on other sites
jdelaney

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.

Share this post


Link to post
Share on other sites
ChrisL

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
Sign in to follow this  

×