weaponx Posted February 21, 2008 Share Posted February 21, 2008 (edited) I am trying to extract a UserName of a created user... it has some sort of namespace thing that I just don't get... Lar. Here you go, this will dump all account info to the console: expandcollapse popup#include <_XMLDomWrapper.au3> #include <Array.au3> $sXMLFile = "Autounattend.xml" $result = _XMLFileOpen($sXMLFile, 'xmlns:un="urn:schemas-microsoft-com:unattend" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"') If $result = 0 Then Exit ;Set root path to LocalAccounts area of xml $path = '//un:unattend/un:settings[@pass="oobeSystem"]/un:component[@name="Microsoft-Windows-Shell-Setup"]/un:UserAccounts/un:LocalAccounts' ;Retrieve count of LocalAccount nodes $accountsArray = _XMLSelectNodes($path & '/*') If IsArray($accountsArray) Then ;_ArrayDisplay($accountsArray) ;Loop through all LocalAccount nodes For $X = 1 to $accountsArray[0] ConsoleWrite("LocalAccount " & $X & @CRLF) ;Count subnodes in LocalAccount (should have Password, Description, DisplayName, Group, Name) $nodesArray = _XMLSelectNodes($path & '/un:LocalAccount/*') ;Dump all LocalAccount info (skip Password since it has subnodes) If IsArray($nodesArray) Then For $Y = 1 to $nodesArray[0] If $nodesArray[$Y] <> "Password" Then ConsoleWrite($nodesArray[$Y] & ": " & _GetFirstValue($path & "/un:LocalAccount[" & $X & "]/un:" & $nodesArray[$Y]) & @CRLF) EndIf Next EndIf ConsoleWrite(@CRLF) Next EndIf ;_XMLGetValue returns an array (not sure why) this will return the first element Func _GetFirstValue($node) $ret_val = _XMLGetValue($node) If IsArray($ret_val) Then Return ($ret_val[1]) Else Return SetError(1,3,0) EndIf EndFunc Sample XML used from here: http://www2.uiowa.edu/clas/it/support/Wind...tendedVista.htm Edited February 21, 2008 by weaponx Link to comment Share on other sites More sharing options...
=sinister= Posted February 21, 2008 Share Posted February 21, 2008 Thanks for your help weaponx, he yeah I made a topic on support because I got impatient waiting for an answer, sorry >< anyways thanks again for the help Link to comment Share on other sites More sharing options...
=sinister= Posted February 23, 2008 Share Posted February 23, 2008 (edited) --NVM THANK YOU-- Edited February 23, 2008 by =sinister= Link to comment Share on other sites More sharing options...
uteotw Posted February 27, 2008 Share Posted February 27, 2008 (edited) Hi AutoIt and XML gurus I'm trying to process the return envelope from a SOAP request. <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <FolderResponse xmlns="http://microsoft.com/workbench/store"> <FolderResult> <Documents Count="3"> <Document DocumentID="1" /> <Document DocumentID="2" /> <Document DocumentID="3" /> </Documents> </FolderResult> </FolderResponse> </soap:Body> </soap:Envelope> I'm trying to access all "DocumentID". But _XMLSelectNodes() can't process past <FolderResponse xmlns="http://microsoft.com/workbench/store"> Here is my AutoIt code: #Include <Array.au3> #Include <_XMLDomWrapper.au3> Local $sFile = "C:\XMLFile1.xml" If FileExists($sFile) Then Local $ret = _XMLFileOpen ($sFile, 'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"') Local $sNodes = _XMLSelectNodes('//soap:Envelope/soap:Body/FolderResponse[@xmlns="http://microsoft.com/workbench/store"]/*') _ArrayDisplay($sNodes, "$sNodes") EndIf Then it works fine. Why is _XMLSelectNodes() failing on [@xmlns="http://microsoft.com/workbench/store"] ? Is it something wrong in my syntax? or is it somthing that the XML DOM Wrapper can't do? Thanks uteotw Edited February 27, 2008 by uteotw Link to comment Share on other sites More sharing options...
weaponx Posted February 27, 2008 Share Posted February 27, 2008 The first thing I see as that the second namespace in your script is a broken link:http://microsoft.com/workbench/store Link to comment Share on other sites More sharing options...
uteotw Posted February 27, 2008 Share Posted February 27, 2008 (edited) The first thing I see as that the second namespace in your script is a broken link: http://microsoft.com/workbench/store True, but does the XML DOM Wrapper try to access that url when processing xmlns attribute? By the way, I'm not the one owning the system generating the XML. I've just found out that if it were <soap:FolderResponse xmlns="http://microsoft.com/workbench/store"> then Local $sNodes = _XMLSelectNodes('//soap:Envelope/soap:Body/soap:FolderResponse/*') would work So, how can I declare before that not all the nodes use the "soap" name space? Edited February 27, 2008 by uteotw Link to comment Share on other sites More sharing options...
weaponx Posted February 27, 2008 Share Posted February 27, 2008 (edited) What is generating this xml? I found no evidence of that namespace ever existing:http://web.archive.org/web/*/http://micros...workbench/storeI did a google search for "http://microsoft.com/workbench/store", "http://microsoft.com/workbench", and "FolderResponse"...nothing found.You can make your code work by stripping: xmlns="http://microsoft.com/workbench/store"Local $sNodes = _XMLSelectNodes('//soap:Envelope/soap:Body/FolderResponse/*')My search for SOAP + envelope returns a lot of xml examples that don't match this at all. Edited February 27, 2008 by weaponx Link to comment Share on other sites More sharing options...
SOARING Posted March 5, 2008 Share Posted March 5, 2008 Hi folks,well i am kinda new and pretty much noob And sometimes i think when i see some code,...(i should really come to the point now.... sorry i am just a girl... i love eMotes )well... i have an XML-File and need a code which reads out some data of the XML-File andput this data into variables (so i stupid one are able to work with it :"> )The XML-File looks like this:<drinks order="4593"><drink id="1" prod="534" name="Milk" oid="361" dd="be_019" og_id="Drink" gid="Medium" avb="1"/><drink id="2" prod="635" name="Coffee" oid="132" dd="be_044" og_id="Drink" gid="Hot" avb="0"/><drink id="3" prod="157" name="Water" oid="173" dd="he_019" og_id="Drink" gid="Cold" avb="1"/></drinks>the data i need is:id, name, og_id, gidand i have no idea how to make it,...is there anyone who please help me and give me a example or something ?(i guess i must use XML-DOM-wrapper somehow ?)Thanks for helping,..Br,Andrea Link to comment Share on other sites More sharing options...
eltorro Posted March 5, 2008 Author Share Posted March 5, 2008 see here. Regards, [indent]ElTorro[/indent][font="Book"] Decide, Commit, Achieve[/font]_ConfigIO.au3Language Translation --uses Google(tm) MsgBox Move XML wrapper UDF XML2TreeView Zip functionality Split your GUI Save Print ScreenZipPluginEdit In Place listviewSome of my scripts on Google code Link to comment Share on other sites More sharing options...
=sinister= Posted March 7, 2008 Share Posted March 7, 2008 Hi, I have one more question, I have an xml file like this: <Key KeyName="Common.TargetParty4" BarState="Indifferent" ShiftState="None" VK="F5" /> <Key KeyName="Common.TargetSelf" BarState="Indifferent" ShiftState="None" VK="F1" /> <Key KeyName="Common.Time1" BarState="Indifferent" ShiftState="None" Char="Undefined" /> <Key KeyName="Common.Time30" BarState="Indifferent" ShiftState="None" Char="Undefined" /> <Key KeyName="Common.Time5" BarState="Indifferent" ShiftState="None" Char="Undefined" /> <Key KeyName="Pogue.Stealth" BarState="Bar5" ShiftState="None" Char="3" /> <Key KeyName="Pogue.Ranged" BarState="Bar6" ShiftState="None" Char="-" /> <Key KeyName="Pogue.Sinister" BarState="Bar1" ShiftState="None" Char="1" /> It has alot more nodes I need to retrieve each first part of the "." in the KeyName. For example, I need to retrieve the "Common" and the "Pogue" in the xml file above. There will be more than 2. Link to comment Share on other sites More sharing options...
weaponx Posted March 7, 2008 Share Posted March 7, 2008 @sinister I think you can figure this out on your own. The only difference from the first code I posted for you is the attribute name, you can use StringSplit to get the first part before the period. Link to comment Share on other sites More sharing options...
eltorro Posted March 7, 2008 Author Share Posted March 7, 2008 Hi, I have one more question, I have an xml file like this: <Key KeyName="Common.TargetParty4" BarState="Indifferent" ShiftState="None" VK="F5" /> <Key KeyName="Common.TargetSelf" BarState="Indifferent" ShiftState="None" VK="F1" /> <Key KeyName="Common.Time1" BarState="Indifferent" ShiftState="None" Char="Undefined" /> <Key KeyName="Common.Time30" BarState="Indifferent" ShiftState="None" Char="Undefined" /> <Key KeyName="Common.Time5" BarState="Indifferent" ShiftState="None" Char="Undefined" /> <Key KeyName="Pogue.Stealth" BarState="Bar5" ShiftState="None" Char="3" /> <Key KeyName="Pogue.Ranged" BarState="Bar6" ShiftState="None" Char="-" /> <Key KeyName="Pogue.Sinister" BarState="Bar1" ShiftState="None" Char="1" /> It has alot more nodes I need to retrieve each first part of the "." in the KeyName. For example, I need to retrieve the "Common" and the "Pogue" in the xml file above. There will be more than 2. I hadn't looked back through all the post but here is a quickie example of what you want. I don't now what weaponx posted for you before but I can't see it being much different. expandcollapse popup#Include <_XMLDomWrapper.au3> Local $xml = '<?xml version="1.0" encoding="utf-16"?> ' & _ '<keys> ' & _ '<Key KeyName="Common.TargetParty4" BarState="Indifferent" ShiftState="None" VK="F5" /> ' & _ '<Key KeyName="Common.TargetSelf" BarState="Indifferent" ShiftState="None" VK="F1" /> ' & _ '<Key KeyName="Common.Time1" BarState="Indifferent" ShiftState="None" Char="Undefined" /> ' & _ '<Key KeyName="Common.Time30" BarState="Indifferent" ShiftState="None" Char="Undefined" /> ' & _ '<Key KeyName="Common.Time5" BarState="Indifferent" ShiftState="None" Char="Undefined" /> ' & _ '<Key KeyName="Pogue.Stealth" BarState="Bar5" ShiftState="None" Char="3" /> ' & _ '<Key KeyName="Pogue.Ranged" BarState="Bar6" ShiftState="None" Char="-" /> ' & _ '<Key KeyName="Pogue.Sinister" BarState="Bar1" ShiftState="None" Char="1" /> ' & _ '</keys>' _XMLLoadXML($xml) ConsoleWrite(_XMLError()&@lf) If @error then MsgBox(0,"Error",_XMLError()) Exit EndIf $var= _XMLSelectNodes("keys/Key") ConsoleWrite(_XMLError()&@lf) If IsArray($var) Then For $x =1 to UBound($var)-1 Local $aNames, $aAttribs ConsoleWrite($var[$x]&":") $sNode = StringFormat("Key[%d]",$x) $attrib= _XMLGetAttrib($sNode,"KeyName") If Not @error Then $pos = StringInstr($attrib,".") If $pos Then $prefix = StringLeft($attrib,StringInstr($attrib,".")-1) ConsoleWrite($prefix&@lf) If $prefix = "Common" or $prefix ="Pogue" Then ConsoleWrite(StringFormat("Node [%d] has prefix %s\n",$x,$prefix)) EndIf EndIf EndIf Next EndIf $objDoc=0 Regards, [indent]ElTorro[/indent][font="Book"] Decide, Commit, Achieve[/font]_ConfigIO.au3Language Translation --uses Google(tm) MsgBox Move XML wrapper UDF XML2TreeView Zip functionality Split your GUI Save Print ScreenZipPluginEdit In Place listviewSome of my scripts on Google code Link to comment Share on other sites More sharing options...
eltorro Posted March 7, 2008 Author Share Posted March 7, 2008 Hi AutoIt and XML gurus I'm trying to process the return envelope from a SOAP request. <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <FolderResponse xmlns="http://microsoft.com/workbench/store"> <FolderResult> <Documents Count="3"> <Document DocumentID="1" /> <Document DocumentID="2" /> <Document DocumentID="3" /> </Documents> </FolderResult> </FolderResponse> </soap:Body> </soap:Envelope> I'm trying to access all "DocumentID". But _XMLSelectNodes() can't process past <FolderResponse xmlns="http://microsoft.com/workbench/store"> Here is my AutoIt code: #Include <Array.au3> #Include <_XMLDomWrapper.au3> Local $sFile = "C:\XMLFile1.xml" If FileExists($sFile) Then Local $ret = _XMLFileOpen ($sFile, 'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"') Local $sNodes = _XMLSelectNodes('//soap:Envelope/soap:Body/FolderResponse[@xmlns="http://microsoft.com/workbench/store"]/*') _ArrayDisplay($sNodes, "$sNodes") EndIf See if this is enough to get you started. I also made some changes to the wrapper to clean up a few things pointed out to me, and some I came across myself. newest version is 1.0.3.87 Regards, [indent]ElTorro[/indent][font="Book"] Decide, Commit, Achieve[/font]_ConfigIO.au3Language Translation --uses Google(tm) MsgBox Move XML wrapper UDF XML2TreeView Zip functionality Split your GUI Save Print ScreenZipPluginEdit In Place listviewSome of my scripts on Google code Link to comment Share on other sites More sharing options...
ken0137 Posted March 9, 2008 Share Posted March 9, 2008 i have a xml file and i want to change the value of Path hwo can i do it expandcollapse popup <?app version="1.0.0.0"?> <!--This is a app config file--> <App> <Function Index="0" SubIndex="2"> <Test> <SN> <Member Path="G:\Work\1.xml" /> </SN> <BT> <Member Path="G:\Work\2.xml" /> </BT> <FT> <Member Path="D:\3.xml" /> </FT> <IMTI> <Member Path="G:\4.xml" /> </IMTI> <BLT> <Member Path="G:\Work5.xml" /> </BLT> <Define> <Member Path="G:\6.xml" /> </Define> </Test> </Function> </App> [code=auto:0] Link to comment Share on other sites More sharing options... ken0137 Posted March 9, 2008 ken0137 Members 18 Share Posted March 9, 2008 (edited) i have a xml file and i want to change the value of first Path " <Member Path="G:\Work\1.xml" />" hwo can i do it <?app version="1.0.0.0"?> <!--This is a app config file--> <App> <Function Index="0" SubIndex="2"> <Test> <SN> <Member Path="G:\Work\1.xml" /> </SN> <BT> <Member Path="G:\Work\2.xml" /> </BT> <FT> <Member Path="D:\3.xml" /> </FT> <IMTI> <Member Path="G:\4.xml" /> </IMTI> <BLT> <Member Path="G:\Work5.xml" /> </BLT> <Define> <Member Path="G:\6.xml" /> </Define> </Test> </Function> </App> Edited March 9, 2008 by ken0137 Link to comment Share on other sites More sharing options...
eltorro Posted March 9, 2008 Author Share Posted March 9, 2008 What do you have for a script so far? Regards, [indent]ElTorro[/indent][font="Book"] Decide, Commit, Achieve[/font]_ConfigIO.au3Language Translation --uses Google(tm) MsgBox Move XML wrapper UDF XML2TreeView Zip functionality Split your GUI Save Print ScreenZipPluginEdit In Place listviewSome of my scripts on Google code Link to comment Share on other sites More sharing options...
ken0137 Posted March 10, 2008 Share Posted March 10, 2008 i have nothing eltorro,your xml udf can"t download the link disabled i just want to kown which func could do it Link to comment Share on other sites More sharing options...
eltorro Posted March 10, 2008 Author Share Posted March 10, 2008 i have nothing eltorro,your xml udf can"t download the link disabled i just want to kown which func could do it No the link not disabled. I just tested it through a proxy server and It worked fine for me. Try again. If you still have difficulty, post back. This should be the syntax and the function you need. _XMLSetAttribute("/App/Function/Test/SN/Member","Path","G:\New.path") I have not tested it with you xml. Regards, [indent]ElTorro[/indent][font="Book"] Decide, Commit, Achieve[/font]_ConfigIO.au3Language Translation --uses Google(tm) MsgBox Move XML wrapper UDF XML2TreeView Zip functionality Split your GUI Save Print ScreenZipPluginEdit In Place listviewSome of my scripts on Google code Link to comment Share on other sites More sharing options...
ken0137 Posted March 10, 2008 Share Posted March 10, 2008 (edited) i com form china ,and the link is disable i use a proxy ,is ok , thanks your help ----------------------- i test it and use _XMLDomWrapper.au3(ver1.0.3.87) but _XMLSetAttribute is not found in _XMLDomWrapper.au3 ??? ---------------------------------------------- are you sure is not _XMLSetAttrib("/App/Function/Test/SN/Member","Path","G:\New.path") Edited March 10, 2008 by ken0137 Link to comment Share on other sites More sharing options...
weaponx Posted March 10, 2008 Share Posted March 10, 2008 i com form china ,and the link is disablei use a proxy ,is ok , thanks your help-----------------------i test itand use _XMLDomWrapper.au3(ver1.0.3.87)but _XMLSetAttribute is not found in _XMLDomWrapper.au3???----------------------------------------------are you sure is not _XMLSetAttrib("/App/Function/Test/SN/Member","Path","G:\New.path")This is correct:_XMLSetAttrib("/App/Function/Test/SN/Member","Path","G:\New.path")The problem is in your XML, the header is invalid.This:<?app version="1.0.0.0"?>Should be:<?xml version="1.0"?> Link to comment Share on other sites More sharing options...
Recommended Posts
eltorro
What do you have for a script so far?
Link to comment
Share on other sites
ken0137
i have nothing
eltorro,your xml udf can"t download
the link disabled
i just want to kown which func could do it
Link to comment
Share on other sites
eltorro
No the link not disabled.
I just tested it through a proxy server and It worked fine for me.
Try again. If you still have difficulty, post back.
This should be the syntax and the function you need.
I have not tested it with you xml.
Link to comment
Share on other sites
ken0137
i com form china ,and the link is disable
i use a proxy ,is ok ,
thanks your help
-----------------------
i test it
and use _XMLDomWrapper.au3(ver1.0.3.87)
but _XMLSetAttribute is not found in _XMLDomWrapper.au3
???
----------------------------------------------
are you sure is not _XMLSetAttrib("/App/Function/Test/SN/Member","Path","G:\New.path")
Edited by ken0137Link to comment
Share on other sites
weaponx
This is correct:
_XMLSetAttrib("/App/Function/Test/SN/Member","Path","G:\New.path")
The problem is in your XML, the header is invalid.
This:
<?app version="1.0.0.0"?>
Should be:
<?xml version="1.0"?>
Link to comment
Share on other sites