ludoo Posted October 28, 2012 Share Posted October 28, 2012 ok , the problem is that the XML file is empty for users. chager to summarize a model with a user creates XML and then modofier. thank you for this new track. Link to comment Share on other sites More sharing options...
ludoo Posted October 29, 2012 Share Posted October 29, 2012 ok, thank you, I corrected the script to get the same result #Include <_XMLDomWrapper.au3> $path = @ScriptDir&"test.xml" $root = "FileZillaServer" _XMLCreateFile ($path, $root, True); create file with root data $hXml= _XMLFileOpen($path) _XMLCreateRootChild("Users", "" , "") Dim $user = "ludo-rds" Dim $Keys[1] Dim $Values[1] $Keys[0] = "Name" $Values[0] = $user _XMLCreateChildWAttr("//Users", "User", $Keys, $Values) $Keys[0] = "Name" $Values[0] = "Pass" ;******************************* _XMLCreateChildNode("//User", "Option", " ", "") ;~ _XMLCreateChildNode("//User", "Option", " ", "") _XMLSetAttrib($root&"/Users/User/Option[1]","Name", "Pass") ;********************************* ;*************************************** _XMLCreateChildNode("//User", "Option", " ", "") _XMLSetAttrib($root&"/Users/User/Option[2]","Name", "Group") ;************************************* _XMLUpdateField("//Option[1]", "") _XMLUpdateField("//Option[2]", "") Link to comment Share on other sites More sharing options...
skin27 Posted October 30, 2012 Share Posted October 30, 2012 If the test.xml already contains the FileZillaServer xml then you don't need to create a new file. For example like this #Include <_XMLDomWrapper.au3> _XMLFileOpen(@ScriptDir&"\test.xml") _XMLUpdateField('/FileZillaServer/Users/User/Option[@Name="Pass"]', "blabla") Link to comment Share on other sites More sharing options...
rossini Posted January 11, 2013 Share Posted January 11, 2013 (edited) Hi,I love the possibility to read and analyze XML files from within AutoIt and your work is just great!I have some trouble to adapt it to my current AutoIt project, though. Maybe you can try and help me.I want to get access to the XML structure within a PPTX (Powerpoint) file.Just as a background: I want to extract embedded movies from Powerpoint 2010 files. A PPTX file is nothing else than a ZIP archive which holds all the media (images, videos), styles (xml), fonts and slide information (xml). I am able to unpack a PPTX file and access files like this:slide1.xml:<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><p:sld xmlns:a="[url="http://schemas.openxmlformats.org/drawingml/2006/main"]http://schemas.openxmlformats.org/drawingml/2006/main[/url]" xmlns:r="[url="http://schemas.openxmlformats.org/officeDocument/2006/relationships"]http://schemas.openxmlformats.org/officeDocument/2006/relationships[/url]" xmlns:p="[url="http://schemas.openxmlformats.org/presentationml/2006/main"]http://schemas.openxmlformats.org/presentationml/2006/main[/url]"><p:cSld> <p:spTree> <p:nvGrpSpPr> <p:cNvPr id="1" name="" /> <p:cNvGrpSpPr /> <p:nvPr /> </p:nvGrpSpPr> <p:grpSpPr> <a:xfrm> <a:off x="0" y="0" /> <a:ext cx="0" cy="0" /> <a:chOff x="0" y="0" /> <a:chExt cx="0" cy="0" /> </a:xfrm> </p:grpSpPr> <p:pic> <p:nvPicPr> <p:cNvPr id="4" name="kniebeuge_trancod_verpixelt.mpg"> <a:hlinkClick r:id="" action="ppaction://media" /> </p:cNvPr> <p:cNvPicPr> <a:picLocks noChangeAspect="1" /> </p:cNvPicPr> <p:nvPr> <a:videoFile r:link="rId2" /> <p:extLst> <p:ext uri="{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}"> <p14:media xmlns:p14="[url="http://schemas.microsoft.com/office/powerpoint/2010/main"]http://schemas.microsoft.com/office/powerpoint/2010/main[/url]" r:embed="rId1" /> </p:ext> </p:extLst> </p:nvPr> </p:nvPicPr> <p:blipFill> <a:blip r:embed="rId4" /> <a:stretch> <a:fillRect /> </a:stretch> </p:blipFill> <p:spPr> <a:xfrm> <a:off x="2628900" y="0" /> <a:ext cx="3886200" cy="6858000" /> </a:xfrm> <a:prstGeom prst="rect"> <a:avLst /> </a:prstGeom> </p:spPr> </p:pic></p:spTree><p:extLst> <p:ext uri="{BB962C8B-B14F-4D97-AF65-F5344CB8AC3E}"> <p14:creationId xmlns:p14="[url="http://schemas.microsoft.com/office/powerpoint/2010/main"]http://schemas.microsoft.com/office/powerpoint/2010/main[/url]" val="986380115" /> </p:ext></p:extLst></p:cSld>...</p:sld>-----------------------------------------------But when opening this xml file and try to access some of the nodes and attributes within, I always get errors.For example, I want to access the attributes for:<p:sld><p:cSld><p:spTree><p:pic><p:nvPicPr><p:cNvPr id=4 name="wahtever.mpg">...But I always get the following error:Dim $xmlfn $xmlfn = @DesktopDir & "\slide1.xml" $myxmlfile = _XMLFileOpen($myxmlfile) dim $aAttName[1],$aAttVal[1] Dim $node, $isitthere $isitthere = _XMLNodeExists("//p:sld") $node = _XMLGetChildNodes("//p:sld/p:cSld/p:spTree/p:pic/p:nvPicPr") ConsoleWrite($node)But ConsoleWrite alsways delivers 0.Can you help me, please? Edited January 11, 2013 by rossini Link to comment Share on other sites More sharing options...
BrewManNH Posted January 11, 2013 Share Posted January 11, 2013 I'm old, can you make that text a bit larger? Also, if that is your code, can't read so not sure what it is, put it inside autoit tags for readability sake. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
rossini Posted January 12, 2013 Share Posted January 12, 2013 I'm old, can you make that text a bit larger? Also, if that is your code, can't read so not sure what it is, put it inside autoit tags for readability sake.I would, but the editor of this forum offers nothing but pure pain to me when I am using copy'n'paste.The first is the content of a normal powerpoint 2010 pptx file, slide1.xml extracted from the pptx which was renamed to .zip.Slide 1 is an empty slide with an embedded video. What you can see there is xml...For quick view with readable font size, please copy and paste it into notepad.exe or something of your choice...I really hope that you're not actually too old... ;-) Link to comment Share on other sites More sharing options...
sut Posted February 2, 2013 Share Posted February 2, 2013 I tried with multiple options but my script seems to always return -1.. Can you please help me My XML: <?xml version="1.0" encoding="UTF-8"?> <testResults> <buildNumber number=1290_100/> <serverName>tc1</serverName> <resultsURL>http://qa-xppro-test/tc1/smokeTest_2013_02_01.html</resultsURL> <testArea name="WebServiceAPITest"> <param name="total">35</param> <param name="pass">35</param> <param name="errors">0</param> <param name="timeTaken">19.36</param> </testArea> <testArea name="restAPI"> <param name="total">35</param> <param name="pass">35</param> <param name="errors">0</param> <param name="timeTaken">19.36</param> </testArea> </testResults> My script: #include <_XMLDomWrapper.au3> #include <File.au3> Global $sFile = "dashboard.xml" If _XMLFileOpen($sFile) Then Local $sLvl = _XMLGetAttrib("/testResults/buildNumber", "number") ConsoleWrite($sLvl & @LF) $groups_count = _XMLGetNodeCount("/testResults/testArea/param") ConsoleWrite($groups_count & @LF) EndIf I am trying to get all the attribute values and node values in a data structure but I am stuck at the first step itself :-( Link to comment Share on other sites More sharing options...
Imbuter2000 Posted June 10, 2013 Share Posted June 10, 2013 General question: I need to crawl many public HTML pages of the wild web with AutoIT by XPATH (and maybe XQUERY). Does this UDF works well on malformed HTML? or my best option is to call (eg. by RunAsWait) a commercial/popular command-line XML parser with tagsoup? What would you recommend for this purpose? Link to comment Share on other sites More sharing options...
Acanis Posted August 13, 2013 Share Posted August 13, 2013 All links down? :/ Link to comment Share on other sites More sharing options...
CFIHS Posted August 14, 2013 Share Posted August 14, 2013 https://raw.github.com/Silvernine0S/FolderMenu3EX/master/Include/_XMLDomWrapper.au3 Link to comment Share on other sites More sharing options...
Imbuter2000 Posted September 21, 2013 Share Posted September 21, 2013 (edited) I'm a newbie with this XML wrapper and I'm getting crazy in understanding why I can't get a simple result like expected. My XML: <root> <sito nome="UNO"> <vista>2013-09-15</vista> <vista>2013-09-20</vista> </sito> <sito nome="DUE"> <vista>2013-09-13</vista> <vista>2013-09-17</vista> <vista>2013-09-20</vista> </sito> </root> First command: $aResult = _XMLGetField("//sito") $aResult: [0] 2 [1] 2013-09-15 [2] 2013-09-20 Why does it "forget" the other three childs? Other command: local $a1[1], $a2[1] $aResult = _XMLGetAllAttrib("//sito",$a1, $a2) $aResult: [0] 1 nome [1] SC Why does it forget the other attribute value "A69"? Edited September 21, 2013 by Imbuter2000 Link to comment Share on other sites More sharing options...
Imbuter2000 Posted October 8, 2013 Share Posted October 8, 2013 I've an XML file like this: <xml xmlns:html="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/xhtml"> <a >test1</a> <a >test2</a> </xml> However, with a _XMLGetValue("//a") I get no results... and I understand that it's because of that namespace. What must I put as second argument of the function _XMLFileOpen to set that namespace? I tried with _XMLFileOpen("c:test.xml", "http://www.w3.org/1999/xhtml") but I still get no results. What's wrong? Link to comment Share on other sites More sharing options...
Imbuter2000 Posted October 10, 2013 Share Posted October 10, 2013 I'm trying the object version. Code: _XMLCreateFile("c:\temp\test.xml", "xml", 1, 1) $o = _XMLFileOpen("c:\temp\test.xml") _XMLCreateRootChild($o, "foo", "bar") Result: <?xml version="1.0" encoding="UTF-8"?> <xml/> _XMLCreateRootChild doesn't return an error. Why does it do nothing? Link to comment Share on other sites More sharing options...
wraithdu Posted October 11, 2013 Share Posted October 11, 2013 _XMLSaveDoc($o, "c:\temp\test.xml") Link to comment Share on other sites More sharing options...
Imbuter2000 Posted October 11, 2013 Share Posted October 11, 2013 _XMLSaveDoc($o, "c:\temp\test.xml") Ah I even decommented the "Global $fXMLAUTOSAVE = True", I thought it was sufficient... How do I set the autosave? Link to comment Share on other sites More sharing options...
wraithdu Posted October 11, 2013 Share Posted October 11, 2013 I completely removed that functionality from my version of the UDF. I didn't like the idea (it would save the document after EVERY operation) and it bloated the code. Feel free to add it back in, but you should design a better implementation. Link to comment Share on other sites More sharing options...
Imbuter2000 Posted October 11, 2013 Share Posted October 11, 2013 Ah... I have to continuously (24/24h) run multiple scripts each containing many XML write/read actions over the same XML file. Do you think that doing an open+action+save for every action would work? What happens if a second script opens or saves the XML file while the first script is doing the same? What's the optimal solution? Link to comment Share on other sites More sharing options...
wraithdu Posted October 11, 2013 Share Posted October 11, 2013 If you have multiple scripts running simultaneously which read/write to the same XML files, then you need to design a synchronization system on your own. The autosave in the old UDF was nothing more that automatically running the save file function after every action function. You should look into file locking or something, where each script would have to obtain a lock on a synchronization file before it can read/write the XML file. If all the scripts run on the same machine, you could also look into mutexes or semaphores. Link to comment Share on other sites More sharing options...
Imbuter2000 Posted October 11, 2013 Share Posted October 11, 2013 (edited) Thanks wraithdu, I will evaluate the best method after some tests. Other questions: 1) What's the purpose of having two independent functions for _XMLCreateRootChild and _XMLCreateChildNode. Can't we just use _XMLCreateChildNode with XPath "/*" when we want to do "_XMLCreateRootChild"? 2) What's the difference betweeb _XMLCreateAttrib and _XMLSetAttrib? they seems to have the same behaviour for creating and modifying (both do both the things) attributes to a given XPath. 3) What's the difference between _XMLDeleteAttr and _XMLDeleteAttrNode? they seem to be for the same purpose of deleting an attribute... Bug (?): 1) _XMLReplaceChild renames the node keeping its attributes but losing their value Edited October 11, 2013 by Imbuter2000 Link to comment Share on other sites More sharing options...
sentry07 Posted October 15, 2013 Share Posted October 15, 2013 https://raw.github.com/Silvernine0S/FolderMenu3EX/master/Include/_XMLDomWrapper.au3 This seems to be an incomplete version of the UDF. It looks like the full version is here: https://raw.github.com/Silvernine0S/FolderMenu3EX/master/Include/_XMLDomWrapper_.au3 All of eltorro's links seem to be dead so hopefully that's a recent version of the UDF. 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