roka Posted September 1, 2011 Share Posted September 1, 2011 Hi All, I'm trying to process a XML file using the _XMLDOMWrapper UDF which worked very well for me so far. Unfortunately I am struggling with a different XML format now. I don't seem to be able to access any nodes after the root node unless I simplify the root node (what I'd like to avoid). Here's the XML format: <Systems Version="3.00" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:schemas-fujitsu-siemens-com:software-preload" xsi:noNamespaceSchemaLocation="HWInfo3.00.xsd"> <System> <SystemIdentification> <SerialNumber>12345XYZ</SerialNumber> <IndividualSoftwareID /> <SystemUUID>{12345XYZ-1234-5678-9123-12345XYZ}</SystemUUID> <CustomerSerialNumber /> <IMEINumber /> <MACAddresses> <MACAddress type="OnBoard">00:12:34:56:78:90</MACAddress> </MACAddresses> </SystemIdentification> <SoftwareModules /> <DeliveryNote> <OrderCode>CUZ:12345XYZ-ABC</OrderCode> <CustomerOrderData>12345XYZ</CustomerOrderData> <EndCustomerOrderNumber>12345XYZ</EndCustomerOrderNumber> <Product>Celsius M470-2</Product> <OrderPosition>123</OrderPosition> <OrderNumber>12345XYZ</OrderNumber> </DeliveryNote> </System> </Systems> AU3 Test: #include <Array.au3> #include <_XMLDomWrapper.au3> Local $inputFile = FileOpenDialog("Select XML", @ScriptDir, "XML (*.xml)", 1) If FileExists($inputFile) Then _XMLFileOpen($inputFile, 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:schemas-fujitsu-siemens-com:software-preload" xsi:noNamespaceSchemaLocation="HWInfo3.00.xsd"') If Not @error Then $aTemp = _XMLGetChildNodes("/Systems") _ArrayDisplay($aTemp) Else MsgBox(0,"Error","Error opening File: " & @error) EndIf EndIf I'm pretty sure my error is in the _XMLFileOpen parameter for the namespace. Unfortunately I don't any experience with XML namespaces and their usage. Any help is much appreciated! Thanks! Link to comment Share on other sites More sharing options...
roka Posted September 6, 2011 Author Share Posted September 6, 2011 ok, so I guess I'll actually modify the XML file before using it. Link to comment Share on other sites More sharing options...
PsaltyDS Posted September 10, 2011 Share Posted September 10, 2011 (edited) What you have is an un-named default namespace. You have to give it a name to be used in the XPath references: #include <Array.au3> #include <_XMLDomWrapper.au3> $debugging = True $sXmlNS = '"urn:schemas-fujitsu-siemens-com:software-preload"' $inputFile = @ScriptDir & "\Test1.xml" If FileExists($inputFile) Then _XMLFileOpen($inputFile, 'xmlns=' & $sXmlNS) If Not @error Then $objDoc.setProperty("SelectionNamespaces", 'xmlns:MyNS=' & $sXmlNS) $aTemp = _XMLGetValue("/MyNS:Systems/MyNS:System/MyNS:SystemIdentification/MyNS:MACAddresses/MyNS:MACAddress") _ArrayDisplay($aTemp) Else MsgBox(0, "Error", "Error opening File: " & @error) EndIf EndIf Edited September 10, 2011 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now