ChrisL Posted August 7, 2008 Share Posted August 7, 2008 I'm a bit confused I have an XML fileexpandcollapse popup<?xml version="1.0"?> <Frontier> <Machine> <ProductName>FRONTIER MP Controller</ProductName> <Version>2.1-0E-010</Version> <PrinterVersion>2.5-0X-120k</PrinterVersion> </Machine> <ProductionLog> <PrintSize> <Name>102 x 152</Name> <Qty>0</Qty> </PrintSize> <PrintSize> <Name>127 x 178</Name> <Qty>0</Qty> </PrintSize> <PrintSize> <Name>152 x 102</Name> <Qty>0</Qty> </PrintSize> <PrintSize> <Name>6x4</Name> <Qty>310</Qty> </PrintSize> <PrintSize> <Name>6x4</Name> </PrintSize> <PrintSize> <Name>5x7</Name> <Qty>183</Qty> </PrintSize> <PrintSize> <Name>6x8</Name> <Qty>7</Qty> </PrintSize> <PrintSize> <Name>6x9</Name> <Qty>82</Qty> </PrintSize> </ProductionLog> </Frontier>But I'm not understanding exactly how to retrieve the data out of the file.This is what I have so far but you will notice that 6x4 doesn't have a <qty> so I can't reliable match arrays $a and $b up.So can someone show me how your supposed to use the DOM Wrapper to get the data please.#include "_XMLDomWrapper.au3" #include <Array.au3> $debugging = 1 $ret = _XMLFileOpen ("ProdLog.xml") $Machine = _GetFirstValue("/Frontier/Machine/ProductName") $Version = _GetFirstValue("/Frontier/Machine/Version") $PVersion = _GetFirstValue("/Frontier/Machine/PrinterVersion") Msgbox(0,"This bit is fine",$Machine & @CRLF & $Version & @CRLF & $PVersion) $a = _XMLGetValue("/Frontier/ProductionLog/PrintSize/Name") $b = _XMLGetValue("/Frontier/ProductionLog/PrintSize/Qty") _ArrayDisplay($a) _ArrayDisplay($b) ;Get the first real value returned from the _XMLGetValue() return array. Func _GetFirstValue($node) $ret_val = _XMLGetValue($node) If IsArray($ret_val) and Ubound($ret_val) > 1 Then Return ($ret_val[1]) Else Return SetError(1,3,0) EndIf EndFuncI'm using eltorro's XML Wrapper [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
ChrisL Posted August 8, 2008 Author Share Posted August 8, 2008 Up for the daytime crowd [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
DjDeep00 Posted August 8, 2008 Share Posted August 8, 2008 @ChrisL...Maybe there is a different way but this is how I would do it... Dim $Final[1] $iNodeCt = _XMLGetNodeCount ("/Frontier/ProductionLog/*") ;MsgBox(4096,"",$iNodeCt) For $x=1 to $iNodeCt $iNodeCt2=_XMLGetNodeCount("/Frontier/ProductionLog/PrintSize[" & $x & "]/*") ;MsgBox(4096,"",$iNodeCt2) $y = _XMLGetChildNodes("/Frontier/ProductionLog/PrintSize[" & $x & "]") ;MsgBox(4096,"","/Frontier/ProductionLog/PrintSize[" & $x & "]") ;_ArrayDisplay($y) For $z=1 to $y[0] $b=_XMLGetValue("/Frontier/ProductionLog/PrintSize[" & $x & "]/" & $y[$z]) ;_ArrayDisplay($b) ;MsgBox(4096,$iNodeCt2,"PrintSize[" & $x & "]=" & $y[$z] & "=" & $b[1]) _ArrayAdd($Final,"PrintSize[" & $x & "]=" & $y[$z] & "=" & $b[1]) Next Next _ArrayDisplay($Final,"") Link to comment Share on other sites More sharing options...
ChrisL Posted August 8, 2008 Author Share Posted August 8, 2008 Thanks very much! [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
weaponx Posted August 8, 2008 Share Posted August 8, 2008 (edited) The original code wasn't bad. I don't really understand what you meant by "couldn't match arrays up". I would have changed this. $a = _XMLGetValue("/Frontier/ProductionLog/PrintSize/Name") $b = _XMLGetValue("/Frontier/ProductionLog/PrintSize/Qty") _ArrayDisplay($a) _ArrayDisplay($b) To this. $a = _XMLGetFirstValue("/Frontier/ProductionLog/PrintSize/Name") $b = _XMLGetFirstValue("/Frontier/ProductionLog/PrintSize/Qty") Then just check if $b is empty or check for @ERROR. Edited August 8, 2008 by weaponx Link to comment Share on other sites More sharing options...
ChrisL Posted August 8, 2008 Author Share Posted August 8, 2008 The original code wasn't bad. I don't really understand what you meant by "couldn't match arrays up". I would have changed this. $a = _XMLGetValue("/Frontier/ProductionLog/PrintSize/Name") $b = _XMLGetValue("/Frontier/ProductionLog/PrintSize/Qty") _ArrayDisplay($a) _ArrayDisplay($b) To this. $a = _XMLGetFirstValue("/Frontier/ProductionLog/PrintSize/Name") $b = _XMLGetFirstValue("/Frontier/ProductionLog/PrintSize/Qty") Then just check if $b is empty or check for @ERROR. It was because I was getting an array of all values in a single go so $a had 8 entries and $b had 7, I hadn't figured out how to run through them 1 PrintSize Node at a time. I keep reading how this XML simplifies things but so far it hasn't simplified any thing for me [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
weaponx Posted August 8, 2008 Share Posted August 8, 2008 I think it doesn't seem simple because of the wrapper itself having to take something object oriented, and making NOT object oriented. If you use ObjCreate to create an "Msxml2.DOMDocument" instance, you might be more comfortable. I personally prefer using XML in Actionscript. Link to comment Share on other sites More sharing options...
ChrisL Posted August 8, 2008 Author Share Posted August 8, 2008 Thanks again for the info [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire 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