Jump to content
Sign in to follow this  
myspacee

Reading XML nodes (Return with conditional operator)

Recommended Posts

myspacee

Hello,

try to read simple XML and i decided to make generic script.

I've a value (140403_0_21_00_XX_C044C021_00N_00F) and i MUST retrieve a value in same node id (="21")

<PubPlain>
  <spread0 id="1" pdfname="140403_0_01_54_MN_M048C001_00N_00F" />
  <spread1 id="2" pdfname="140403_0_02_00_XX_C002C047_00N_00F" />
  <spread2 id="3" pdfname="140403_0_03_54_XX_CL16C003_00N_00F" />
  <spread3 id="4" pdfname="140403_0_04_54_XX_C004CL15_00N_00F" />
  <spread4 id="5" pdfname="140403_0_05_54_XX_ML14M005_00N_00F" />
  <spread5 id="6" pdfname="140403_0_06_54_XX_C006CL13_00N_00F" />
  <spread6 id="7" pdfname="140403_0_07_54_XX_CL12C007_00N_00F" />
  <spread7 id="8" pdfname="140403_0_08_54_XX_C008CL11_00N_00F" />
  <spread8 id="9" pdfname="140403_0_09_54_XX_CL10C009_00N_00F" />
  <spread9 id="10" pdfname="140403_0_10_54_XX_M010CL09_00N_00F" />
  <spread10 id="11" pdfname="140403_0_11_54_XX_CL08C011_00N_00F" />
  <spread11 id="12" pdfname="140403_0_12_54_XX_C012CL07_00N_00F" />
  <spread12 id="13" pdfname="140403_0_13_54_XX_CL06C013_00N_00F" />
  <spread13 id="14" pdfname="140403_0_14_54_XX_C014CL05_00N_00F" />
  <spread14 id="15" pdfname="140403_0_15_54_XX_CL04C015_00N_00F" />
  <spread15 id="16" pdfname="140403_0_16_54_XX_C016CL03_00N_00F" />
  <spread16 id="17" pdfname="140403_0_17_54_XX_CL02C017_00N_00F" />
  <spread17 id="18" pdfname="140403_0_18_54_XX_C018CL01_00N_00F" />
  <spread18 id="19" pdfname="140403_0_19_00_XX_C046C019_00N_00F" />
  <spread19 id="20" pdfname="140403_0_20_00_XX_C020C045_00N_00F" />
  <spread20 id="21" pdfname="140403_0_21_00_XX_C044C021_00N_00F" />
  <spread21 id="22" pdfname="140403_0_22_00_XX_M022C043_00N_00F" />
  <spread22 id="23" pdfname="140403_0_23_00_XX_C042C023_00N_00F" />
  <spread23 id="24" pdfname="140403_0_24_00_XX_C024C041_00N_00F" />
  <spread24 id="25" pdfname="140403_0_25_00_XX_M040C025_00N_00F" />
  <spread25 id="26" pdfname="140403_0_26_00_XX_C026C039_00N_00F" />
  <spread26 id="27" pdfname="140403_0_27_00_XX_C038C027_00N_00F" />
  <spread27 id="28" pdfname="140403_0_28_00_XX_C028C037_00N_00F" />
  <spread28 id="29" pdfname="140403_0_29_00_XX_C036C029_00N_00F" />
  <spread29 id="30" pdfname="140403_0_30_00_XX_C030C035_00N_00F" />
  <spread30 id="31" pdfname="140403_0_31_00_XX_M034C031_00N_00F" />
  <spread31 id="32" pdfname="140403_0_32_00_XX_C032C033_00N_00F" />
</PubPlain>

My XMLs are simple but tend to vary in certain conditions. So i haven't any sure foothold, I must read XML everytime.

I've read several approaches to XML reading but can't determine which best.

(dead?) _XMLDomWrapper.au3 seems to be the best choice;

can you suggest best way to implement XML reading in AI ?

Thank you,

m.

Share this post


Link to post
Share on other sites
jdelaney

This is with no error handling...your script will blowup if the 'pdfname' is not found...you can break it out, and do the error handling yourself:

$file = @DesktopDir & "\temp.xml"
$oXML = ObjCreate("Microsoft.XMLDOM")
$oXML.load($file)
$id = $oXML.selectSingleNode("//PubPlain/*[@pdfname='140403_0_21_00_XX_C044C021_00N_00F']").GetAttribute("id")
ConsoleWrite($id & @CRLF)

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
dynamitemedia

i have been trying to get this to work using a code that you gave me in another thread but its not working at all  i want to search the xml by  ID=2 for example

$file = "<channels><channel ID='2' url='http://videe.com/index.php/channel/3a9a071' name='Guest1588664 live from Android' quality='best'/> <channel ID='3' url='http://videe.com/index.php/channel/ea579cc92d' name='boulon live' quality='best'/> <channel ID='4' url='http://videe.com/index.php/channel/290a3a52b' name='frank11262' quality='best'/> <channel ID='5' url='http://videe.com/index.php/channel/ab6c066e' name='REAL MADRID  #  LIVERPOOL 19:45 gmt' quality='best'/> </channels>"


$oXML = ObjCreate("Microsoft.XMLDOM")
$oXML.load($file)
$id = $oXML.selectSingleNode("//channels/*[@ID='2']").GetAttribute("url")
msgbox(4096, "test", $id)

but i am getting nothing back

what am i doing wrong?

Share this post


Link to post
Share on other sites
jdelaney

use .load() when you are loading a file...when loading a string...

$file = "<channels><channel ID='2' url='http://videe.com/index.php/channel/3a9a071' name='Guest1588664 live from Android' quality='best'/> <channel ID='3' url='http://videe.com/index.php/channel/ea579cc92d' name='boulon live' quality='best'/> <channel ID='4' url='http://videe.com/index.php/channel/290a3a52b' name='frank11262' quality='best'/> <channel ID='5' url='http://videe.com/index.php/channel/ab6c066e' name='REAL MADRID  #  LIVERPOOL 19:45 gmt' quality='best'/> </channels>"

$oXML = ObjCreate("Microsoft.XMLDOM")
$oXML.loadxml($file)
$id = $oXML.selectSingleNode("//channels/*[@ID='2']").GetAttribute("url")
msgbox(4096, "test", $id)
  • Like 1

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
dynamitemedia

well now after further testing  when i try to load a XML file it come back blank and this is the code i used and XML looks the same in the variable above.

$xml = @ScriptDir &  "\videe.xml"
msgbox(4096, "test", $xml)


$oXML = ObjCreate("Microsoft.XMLDOM")
$oXML.load($xml)
$id = $oXML.selectSingleNode("//channels/*[@ID='41']").GetAttribute("url")
; $id = $oXML.selectSingleNode("//*[@ID='41']").GetAttribute("url")

msgbox(4096, "test", $id & @CRLF)

is it cause the variable you used above is like all 1 line of XML?

Share this post


Link to post
Share on other sites
jdelaney

If the XML is not valid, then you can't use the xmldom.

Put consolewrite($oXML.xml & @crlf) after you load in the xml...if it's empty, then the XML is not valid.  Otherwise, I can't read minds, or files on outside computers.

Edited by jdelaney

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
dynamitemedia

the xml i have is just as we had above and looks like this:

<channels>
<channel ID='2' url='http://videe.com/index.php/channel/3a9a071' name='Guest1588664 live from Android' quality='best'/>
<channel ID='3' url='http://videe.com/index.php/channel/ea579cc92d' name='boulon live' quality='best'/>
<channel ID='4' url='http://videe.com/index.php/channel/290a3a52b' name='frank11262' quality='best'/>
<channel ID='5' url='http://videe.com/index.php/channel/ab6c066e' name='REAL MADRID  #  LIVERPOOL 19:45 gmt' quality='best'/>
</channels>

you had this above

$file = "<channels><channel ID='2' url='http://videe.com/index.php/channel/3a9a071' name='Guest1588664 live from Android' quality='best'/> <channel ID='3' url='http://videe.com/index.php/channel/ea579cc92d' name='boulon live' quality='best'/> <channel ID='4' url='http://videe.com/index.php/channel/290a3a52b' name='frank11262' quality='best'/> <channel ID='5' url='http://videe.com/index.php/channel/ab6c066e' name='REAL MADRID  #  LIVERPOOL 19:45 gmt' quality='best'/> </channels>"

i do not get what is the difference in these files?  but its coming back  

>"C:Program FilesAutoIt3SciTE..autoit3.exe" /ErrorStdOut "C:Documents and SettingssettopDesktopsearch XML.au3" 

 

Share this post


Link to post
Share on other sites
jdelaney

That doesn't help...again, can't read minds, or your consol output...you only provided a small portion of a total picture that's needed to provide any constructive help.


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
dynamitemedia

sorry but i gave you exactly what i was working with and what the console said which was blank...

i came up with a way to get it to work for now and since the XML may be formatted incorrectly it is the way i get it.

so i did this and it seems to work 

#include <Process.au3>
#include <Constants.au3>
#include <String.au3>
#include <Array.au3>

   Local Const $xmlFile = 'C:\Documents and Settings\settop\Desktop\videe.xml'
   $xml=FileRead($xmlFile)
   $colName ="2"
   $sSearch=_StringBetween($xml,"<channel ID='" & $colName & "'","/>")
   $sResult=_ArrayToString($sSearch,"")

   Local $splitXML = StringSplit($sResult, "'")
   For $i = 1 To $splitXML[0]
   Next

   msgbox(0, "URL",  $splitXML[2] & @CRLF)
   msgbox(0, "Name",  $splitXML[4] & @CRLF)
   msgbox(0, "Quality",  $splitXML[6] & @CRLF)

and once again the "xml" looks like this:

<channels>
<channel ID='2' url='http://videe.com/index.php/channel/3a9a071' name='Guest1588664 live from Android' quality='best'/> 
<channel ID='3' url='http://videe.com/index.php/channel/ea579cc92d' name='boulon live' quality='best'/> 
<channel ID='4' url='http://videe.com/index.php/channel/290a3a52b' name='frank11262' quality='best'/> 
<channel ID='5' url='http://videe.com/index.php/channel/ab6c066e' name='REAL MADRID  #  LIVERPOOL 19:45 gmt' quality='best'/> 
</channels>

it must not be reading it as XML .   do you see what i did and is there an easier way to do it?

Share this post


Link to post
Share on other sites
jdelaney

Works fine for me:

ConsoleWrite(FileRead("some.xml") & @CRLF)
$oXML = ObjCreate("Microsoft.XMLDOM")
$oXML.load("some.xml")
ConsoleWrite($oXML.xml & @CRLF)
$id = $oXML.selectSingleNode("//channels/*[@ID='2']").GetAttribute("url")
ConsoleWrite($id & @CRLF)

output:

<channels>
<channel ID='2' url='http://videe.com/index.php/channel/3a9a071' name='Guest1588664 live from Android' quality='best'/>
<channel ID='3' url='http://videe.com/index.php/channel/ea579cc92d' name='boulon live' quality='best'/>
<channel ID='4' url='http://videe.com/index.php/channel/290a3a52b' name='frank11262' quality='best'/>
<channel ID='5' url='http://videe.com/index.php/channel/ab6c066e' name='REAL MADRID  #  LIVERPOOL 19:45 gmt' quality='best'/>
</channels>
<channels>
 <channel ID="2" url="http://videe.com/index.php/channel/3a9a071" name="Guest1588664 live from Android" quality="best"/>
 <channel ID="3" url="http://videe.com/index.php/channel/ea579cc92d" name="boulon live" quality="best"/>
 <channel ID="4" url="http://videe.com/index.php/channel/290a3a52b" name="frank11262" quality="best"/>
 <channel ID="5" url="http://videe.com/index.php/channel/ab6c066e" name="REAL MADRID  #  LIVERPOOL 19:45 gmt" quality="best"/>
</channels>

http://videe.com/index.php/channel/3a9a071


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
dynamitemedia

 that is strange,  am i missing an include file or something?

cause it fails printing to console on the second console write command here:

$oXML.load("C:\Documents and Settings\settop\Desktop\videe.xml")
ConsoleWrite($oXML.xml & @CRLF)

or is it just correct xml?

the first one works and prints out just fine

Edited by dynamitemedia

Share this post


Link to post
Share on other sites
jdelaney

No includes are necessary...and you are still not posting back enough information...why didn't you include the fileread output?

I want the output from the consol, not what you think the file contains.

Edited by jdelaney

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
dynamitemedia

sorry cause honestly totally new to this and not 100% what i am supposed to show... i am only getting the 1st one showing in console and second one shows nothing   

this is the whole code, the fileread output works just fine but its a lot so i commented it out

;ConsoleWrite(FileRead("C:\Documents and Settings\settop\Desktop\videe.xml") & @CRLF)
$oXML = ObjCreate("Microsoft.XMLDOM")
$oXML.load("C:\Documents and Settings\settop\Desktop\Desktop\videe.xml")
ConsoleWrite($oXML.xml & @CRLF)
$id = $oXML.selectSingleNode("//channels/*[@ID='2']").GetAttribute("url")
ConsoleWrite($id & @CRLF)

console read this:

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Documents and Settings\settop\Desktop\test.au3"    


>Exit code: 0    Time: 0.3512

If that is not what your asking for i am sorry cause i just started using this 2 days ago i am used to bat and echo etc...  i was using Notepad++ till yesterday as well.   Not trying to be difficult just not familiar with the program yet 

Edited by dynamitemedia

Share this post


Link to post
Share on other sites
jdelaney

Well, obviously, your xml does not contain exactly what you posted above...and since I can't see it, I assume it's faulty.

Good luck.

Keep going the regular expression route...I'm not the best at those, so would leave it to others to answer.

Edited by jdelaney
  • Like 1

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

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  

  • Similar Content

    • Subz
      By Subz
      Can anyone assist with creating/modify/delete XML Nodes/Child Nodes?
      Have a document for example:
      <ConfigData> <parameter> <name>Setting One</name> <value>10</value> </parameter> <parameter> <name>IPAddress</name> <value>192.168.1.1</value> </parameter> <parameter> <name>Setting One</name> <value>200</value> </parameter> <parameter> <name>Setting Three</name> <value>300</value> </parameter> </ConfigData> Would like to add another node parameter/name, parameter/value, but unsure how to, when there are multiple instances with the same tagname for example, would like to add the following if the nodes do not already exist:
      <parameter> <name>UserPreferredLanguage</name> <value>English</value> </parameter> Currently using the following to check and delete/modify existing nodes, was thinking of placing the name and value into a 2d array and then using a true/false in a 3rd column to return if the setting was found and modified or not, so I can decide whether I need to create the nodes or not, but I'm hoping there is a simpler way.\
      Any assistance would be much appreciated.
      PS: Have also written this with the XML Dom Wrapper UDF but still unsure how to proceed with checking nodes and creating them if they're missing, also couldn't find a function to delete a full node + parent using selectNodes, hence the custom __XML_DeleteNode function.
      Thanks
      Local $sXMLDocPath = @ScriptDir & "\XMLDoc.xml" Local $oXMLDoc = ObjCreate("MSXML2.DOMDocument") $oXMLDoc.validateOnParse = False $oXMLDoc.load($sXMLDocPath) Local $oXMLNodes = $oXMLDoc.selectNodes("ConfigData/parameter") If IsObj($oXMLNodes) Then For $oXMLNode In $oXMLNodes If $oXMLNode.childNodes.item(0).tagName = "Name" And $oXMLNode.childNodes.item(0).Text = "Setting One" Then If $oXMLNode.childNodes.item(1).tagName = "Value" Then $oXMLNode.childNodes.item(1).Text = 10 EndIf If $oXMLNode.childNodes.item(0).tagName = "Name" And $oXMLNode.childNodes.item(0).Text = "IPAddress" Then __XML_DeleteNode($oXMLNode) EndIf If $oXMLNode.childNodes.item(0).tagName = "Name" And $oXMLNode.childNodes.item(0).Text = "Setting Two" Then If $oXMLNode.childNodes.item(1).tagName = "Value" Then $oXMLNode.childNodes.item(1).Text = 20 EndIf If $oXMLNode.childNodes.item(0).tagName = "Name" And $oXMLNode.childNodes.item(0).Text = "Setting Three" Then If $oXMLNode.childNodes.item(1).tagName = "Value" Then $oXMLNode.childNodes.item(1).Text = 30 EndIf Next EndIf $oXMLDoc.Save ($sXMLDocPath) Func __XML_DeleteNode($_oNode_Enum) If $_oNode_Enum.hasChildNodes Then For $_oNode_Enum_Child In $_oNode_Enum.childNodes If $_oNode_Enum_Child.nodeType = $XML_NODE_TEXT Then If StringStripWS($_oNode_Enum_Child.text, $STR_STRIPLEADING + $STR_STRIPTRAILING + $STR_STRIPSPACES) = "" Then $_oNode_Enum.removeChild($_oNode_Enum_Child) EndIf EndIf Next EndIf $_oNode_Enum.parentNode.removeChild($_oNode_Enum) EndFunc  
    • PedroWarlock
      By PedroWarlock
      (GOOGLE TRANSLATOR) Sorry: /
      Sorry, there is no new difficulty to organize my reading system, I need an XLM file like that, which is the problem with 30 thousand lines, is this, I need to find the value "Difficulty" and "live" and tell the program what's with the "default =" yes "" not <dipvalue>, can anyone have an example of how I wanted to do this? An example is enough to do this.
      example.au3
      #include <Array.au3> #include "XML.au3" _Example() Func _Example() Local $oXML = _XML_CreateDOMDocument(Default) Local $sXML_Content =@ScriptDir & "\file.xml" _XML_Load($oXML, $sXML_Content) ; ~ _XML_LoadXML($oXML, $sXML) Local $iNodeCount = _XML_GetNodesCount($oXML, "/mame/game") ConsoleWrite("Group(s): $iNodeCount = " & $iNodeCount & "; @error = " & @error & "; @extended = " & @extended & @LF) Local $aNames = _XML_GetValue($oXML, "/mame/game/description") Local $aTaxCountries = _XML_GetValue($oXML, "/mame/game/manufacturer") Local $aData[$iNodeCount + 1][4] = [[$iNodeCount, "", ""]] For $n = 1 To $iNodeCount Local $oNode_Selected_SingleOne = _XML_SelectSingleNode($oXML, '/mame/game/dipswitch[' & $n & ']') Local $sAttribute_Value = _XML_GetNodeAttributeValue($oNode_Selected_SingleOne, 'name') Local $oNode_Selected_SingleOne2 = _XML_SelectSingleNode($oXML, '/mame/game/dipswitch/dipvalue[' & $n & ']') Local $sAttribute_Value2 = _XML_GetNodeAttributeValue($oNode_Selected_SingleOne2, 'name') $aData[$n][0] = $aNames[$n] $aData[$n][1] = $aTaxCountries[$n] $aData[$n][2] = $sAttribute_Value $aData[$n][3] = $sAttribute_Value2 Next _ArrayDisplay($aData, "$aData") EndFunc ;==>_Example  
      file.xml
      <mame build="0.124a BRarcade(Mar 31 2008)" debug="no"> <game name="puckman" sourcefile="pacman.c"> <description>PuckMan (Japan set 1, Probably Bootleg)</description> <dipswitch name="Service Mode"> <dipvalue name="Off" default="yes"/> <dipvalue name="On"/> </dipswitch> <dipswitch name="Cabinet"> <dipvalue name="Upright" default="yes"/> <dipvalue name="Cocktail"/> </dipswitch> <dipswitch name="Coinage"> <dipvalue name="2 Coins/1 Credit"/> <dipvalue name="1 Coin/1 Credit" default="yes"/> <dipvalue name="1 Coin/2 Credits"/> <dipvalue name="Free Play"/> </dipswitch> <dipswitch name="Lives"> <dipvalue name="1"/> <dipvalue name="2"/> <dipvalue name="3" default="yes"/> <dipvalue name="5"/> </dipswitch> <dipswitch name="Bonus Life"> <dipvalue name="10000" default="yes"/> <dipvalue name="15000"/> <dipvalue name="20000"/> <dipvalue name="None"/> </dipswitch> <dipswitch name="Difficulty"> <dipvalue name="Normal" default="yes"/> <dipvalue name="Hard"/> </dipswitch> </game> <game name="puckmana" sourcefile="pacman.c" cloneof="puckman" romof="puckman"> <description>PuckMan (Japan set 2)</description> <dipswitch name="Rack Test (Cheat)"> <dipvalue name="Off" default="yes"/> <dipvalue name="On"/> </dipswitch> <dipswitch name="Service Mode"> <dipvalue name="Off" default="yes"/> <dipvalue name="On"/> </dipswitch> <dipswitch name="Cabinet"> <dipvalue name="Upright" default="yes"/> <dipvalue name="Cocktail"/> </dipswitch> <dipswitch name="Coinage"> <dipvalue name="2 Coins/1 Credit"/> <dipvalue name="1 Coin/1 Credit" default="yes"/> <dipvalue name="1 Coin/2 Credits"/> <dipvalue name="Free Play"/> </dipswitch> <dipswitch name="Lives"> <dipvalue name="1"/> <dipvalue name="2"/> <dipvalue name="3" default="yes"/> <dipvalue name="5"/> </dipswitch> <dipswitch name="Difficulty"> <dipvalue name="Normal" default="yes"/> <dipvalue name="Hard"/> </dipswitch> </game> <game name="puckmanf" sourcefile="pacman.c" cloneof="puckman" romof="puckman"> <dipswitch name="Cabinet"> <dipvalue name="Upright" default="yes"/> <dipvalue name="Cocktail"/> </dipswitch> <dipswitch name="Lives"> <dipvalue name="1"/> <dipvalue name="2"/> <dipvalue name="3" default="yes"/> <dipvalue name="5"/> </dipswitch> <dipswitch name="Difficulty"> <dipvalue name="Normal" default="yes"/> <dipvalue name="Hard"/> </dipswitch> <dipswitch name="Ghost Names"> <dipvalue name="Normal" default="yes"/> <dipvalue name="Alternate"/> </dipswitch> </game> <game name="puckmanh" sourcefile="pacman.c" cloneof="puckman" romof="puckman"> <dipswitch name="Coinage"> <dipvalue name="2 Coins/1 Credit"/> <dipvalue name="1 Coin/1 Credit" default="yes"/> <dipvalue name="1 Coin/2 Credits"/> <dipvalue name="Free Play"/> </dipswitch> <dipswitch name="Lives"> <dipvalue name="1"/> <dipvalue name="2"/> <dipvalue name="3" default="yes"/> <dipvalue name="5"/> </dipswitch> <dipswitch name="Bonus Life"> <dipvalue name="10000" default="yes"/> <dipvalue name="15000"/> <dipvalue name="20000"/> <dipvalue name="None"/> </dipswitch> <dipswitch name="Difficulty"> <dipvalue name="Normal" default="yes"/> <dipvalue name="Hard"/> </dipswitch> </game> <game name="pacman" sourcefile="pacman.c" cloneof="puckman" romof="puckman"> <dipswitch name="Cabinet"> <dipvalue name="Upright" default="yes"/> <dipvalue name="Cocktail"/> </dipswitch> <dipswitch name="Coinage"> <dipvalue name="2 Coins/1 Credit"/> <dipvalue name="1 Coin/1 Credit" default="yes"/> <dipvalue name="1 Coin/2 Credits"/> <dipvalue name="Free Play"/> </dipswitch> <dipswitch name="Lives"> <dipvalue name="1"/> <dipvalue name="2"/> <dipvalue name="3" default="yes"/> <dipvalue name="5"/> </dipswitch> <dipswitch name="Bonus Life"> <dipvalue name="10000" default="yes"/> <dipvalue name="15000"/> <dipvalue name="20000"/> <dipvalue name="None"/> </dipswitch> </game> <game name="pacmanf" sourcefile="pacman.c" cloneof="puckman" romof="puckman"> <dipswitch name="Coinage"> <dipvalue name="2 Coins/1 Credit"/> <dipvalue name="1 Coin/1 Credit" default="yes"/> <dipvalue name="1 Coin/2 Credits"/> <dipvalue name="Free Play"/> </dipswitch> <dipswitch name="Lives"> <dipvalue name="1"/> <dipvalue name="2"/> <dipvalue name="3" default="yes"/> <dipvalue name="5"/> </dipswitch> <dipswitch name="Bonus Life"> <dipvalue name="10000" default="yes"/> <dipvalue name="15000"/> <dipvalue name="20000"/> <dipvalue name="None"/> </dipswitch> <dipswitch name="Difficulty"> <dipvalue name="Normal" default="yes"/> <dipvalue name="Hard"/> </dipswitch> <dipswitch name="Ghost Names"> <dipvalue name="Normal" default="yes"/> <dipvalue name="Alternate"/> </dipswitch> <driver status="good" emulation="good" color="good" sound="good" graphic="good" savestate="supported" palettesize="512"/> </game> </mame>
    • Simpel
      By Simpel
      Hi. I'm trying to write a xml. Here is my code:
      #include <_XMLDomWrapper.au3> #include <Date.au3> Global $g_sXMLFileName Global $g_sDestPath = @DesktopDir & "\" Global $g_sReturnedBID = "A10829" _makeXML() _AddXML(1, "A10829_Thomas/wav/T001.wav") _AddXML(2, "A10829_Thomas/wav/T002.wav") Exit Func _makeXML() Local $sXMLtime = StringReplace(StringReplace(StringReplace(_NowCalc()," ","_"),":","-"),"/","-") ; in yyyy-mm-dd_hh-mm-ss $g_sXMLFileName = $g_sDestPath & $g_sReturnedBID & "_" & "EB-Ton-Upload" & "_" & $sXMLtime & ".xml" _XMLCreateFile($g_sXMLFileName, "gemagvl", 1,1) _XMLFileOpen($g_sXMLFileName) EndFunc Func _AddXML($iCount, $sDateiname) _XMLCreateRootNodeWAttr("row", "count", $iCount, "") _XMLCreateChildNode("//row", "picklistenname", $g_sReturnedBID & "_EB-Ton-Upload") _XMLCreateChildNode("//row", "picklisteninfo") _XMLCreateChildNode("//row", "bid", $g_sReturnedBID) _XMLCreateChildNode("//row", "audiodateiname", $sDateiname) _XMLCreateChildNode("//row", "titel", StringTrimRight(StringTrimLeft($sDateiname, 7), 4)) _XMLCreateChildNode("//row", "interpret", "EB") _XMLCreateChildNode("//row", "quelle", "Ton") EndFunc It returns:
      <?xml version="1.0" encoding="UTF-8"?><gemagvl> <row count="1"> <picklistenname>A10829_EB-Ton-Upload</picklistenname> <picklisteninfo/> <bid>A10829</bid> <audiodateiname>A10829_Thomas/wav/T001.wav</audiodateiname> <titel>Thomas/wav/T002</titel> <interpret>EB</interpret> <quelle>Ton</quelle> <picklistenname>A10829_EB-Ton-Upload</picklistenname> <picklisteninfo/> <bid>A10829</bid> <audiodateiname>A10829_Thomas/wav/T002.wav</audiodateiname> <titel>Thomas/wav/T003</titel> <interpret>EB</interpret> <quelle>Ton</quelle> </row> <row count="2"> <picklistenname>A10829_EB-Ton-Upload</picklistenname> <picklisteninfo/> <bid>A10829</bid> <audiodateiname>A10829_Thomas/wav/T002.wav</audiodateiname> <titel>Thomas/wav/T003</titel> <interpret>EB</interpret> <quelle>Ton</quelle> </row> </gemagvl> But it should return:
      <?xml version="1.0" encoding="UTF-8"?><gemagvl> <row count="1"> <picklistenname>A10829_EB-Ton-Upload</picklistenname> <picklisteninfo/> <bid>A10829</bid> <audiodateiname>A10829_Thomas/wav/T001.wav</audiodateiname> <titel>Thomas/wav/T002</titel> <interpret>EB</interpret> <quelle>Ton</quelle> </row> <row count="2"> <picklistenname>A10829_EB-Ton-Upload</picklistenname> <picklisteninfo/> <bid>A10829</bid> <audiodateiname>A10829_Thomas/wav/T002.wav</audiodateiname> <titel>Thomas/wav/T003</titel> <interpret>EB</interpret> <quelle>Ton</quelle> </row> </gemagvl> The second inserted nodes are double. How will it be going right?
      Regards, Conrad
    • rootx
      By rootx
      I need help to read in a loop the DVD id child and subchild. Thx
      Example...
      DVD001 - PAL - EN,FR,DE,ES,IT and filter the right title & descri language.  I tried with $oXML.SelectSingleNode but without success
      <?xml version="1.0" encoding="UTF-8"?> <datafile xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="mydvd.xsd"> <dvd name="My dvd title"> <id>DVD001</id> <region>PAL</region> <languages>EN,FR,DE,ES,IT</languages> <locale lang="EN"> <title>title en</title> <descri>descri en</descri> </locale> <locale lang="FR"> <title>title fr</title> <descri>descri fr </descri> </locale> <locale lang="DE"> <title>title de</title> <descri>descri de </descri> </locale> <locale lang="ES"> <title>title es</title> <descri>descri es</descri> </locale> <locale lang="IT"> <title>title it</title> <descri>descri it</descri> </locale> </dvd> <dvd name="My dvd title 2"> <id>DVD002</id> <region>USA</region> <languages>EN</languages> <locale lang="EN"> <title>title en</title> <descri>descri en</descri> </locale> </dvd> </datafile> #include <File.au3> $xml = @ScriptDir&"\test.xml" Local $oXML = ObjCreate("Microsoft.XMLDOM") $oXML.load($xml) $id = $oXML.SelectNodes("//dvd") For $ids In $id ConsoleWrite($ids.text &@CRLF) Next  
    • mLipok
      By mLipok
      I was asking @eltorro serveral times for any support  for XML DOM wrapper (COM) - with no success  
          So I took matters into my hands ..... I want to present XMLWrapperEx.au3 - BETA Version
      Want to join to the project ?
       
      Here is some description:
      ; #INDEX# ======================================================================================================================= ; Title .........: XMLWrapperEx.au3 ; AutoIt Version : 3.3.10.2++ ; Language ......: English ; Description ...: Functions to use for reading and writing XML using msxml. ; Remarks .......: BETA Version ; Author ........: mLipok ; Version .......: "1.1.1.01" ; _XML_MiscProperty_UDFVersion() #CS This UDF is created on the basis of: https://www.autoitscript.com/forum/topic/19848-xml-dom-wrapper-com/ For this reason, I attach also the last known (to me) previous version ($_XMLUDFVER = "1.0.3.98" _XMLDomWrapper_1.0.3.98_CN.au3 ) For the same reason I continue to recognize the achievements of the work of my predecessors (they are still noted in each Function header). . . . . !!!!!!!!! This is BETA VERSION (all could be changed) !!!!!!!!! . . . WORK IN PROGRES INFORMATION: For now 2015-09-01 the descripion (Function Header) can not entirely correctly describe the function. TODO: in many places I used "TODO" as a keyword to find what should be done in future . I want to: PREVENT THIS: The unfortunate nature of both the scripts is that the func return results are strings or arrays instead of objects. .     I want to: USE THIS CONCEPT:     .   All function should use Refernce to the object as first Function parameter     .   All function should return in most cases objects. There should be separate functions to Change Object collection to array     .   All function should use COM Error Handler in local scope.     .   All function should return @error which are defined in #Region XMLWrapperEx.au3 - @ERROR Enums     .    All function should have the same naming convention     .    All variables should have the same naming convention     .    There should not to be any Global Variable - exception is $g__oXMLDOM_Events     .   It should be possible easy to use XML DOM Events     .        https://msdn.microsoft.com/en-us/library/ms764697(v=vs.85).aspx     .   It should be possible easy to Debug     .    Ultimately, you should be able to do anything with your XML without having to use your own Error Handler. #CE  
      More info inside zip archive.
      This UDF can be downloaded from here:
      REMARK:
      This UDF was formerly named:   XMLWrapperEx.au3 
       
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.