Jump to content

XML DOM wrapper (COM)


eltorro
 Share

Recommended Posts

Hmmm, I'm trying this and getting errors:

Case $Button_15
                $userGroup = GUICtrlRead($Combo_2)
                $userName = GUICtrlRead($Combo_4)
                _XMLDeleteNode(StringFormat('//sudo:sudoers/sudo:users/sudo:userGroup[@name="%s"]/sudo:user[@name="%s"]',$userGroup,$userName))
                _Refresh()

And the Gui maps to the above script so they show the usergroup and username ...

I get COM error with DOM:

err.windescription: Not and Object type

...

err.scriptline is 486

In the Scite editor I see:

Attribute commandGroupName not found for: //sudo:sudoers/sudo:users/sudo:userGroup[@name="Administrators"]/sudo:commandGroupRefs/sudo:commandGroupRef

No qualified items found

I don't know if that helps, but I don't know what's going on.

Link to comment
Share on other sites

Hi,

I am trying to get a attribute so then the i can see what the defualt port.

Once i can get that value i then can add it to a text box an change it

like in

$var = _XMLGetAttrib('/tv/channel[@id="01"]/icon',"src")

for

<SystemProperty name="jetty.port" default="8081" />

default="8081"

could you show what i need to call here is the xml;

---------------------------------------

<?xml version="1.0" ?>

<!DOCTYPE Configure (View Source for full doctype...)>

- <!-- ===============================================================

-->

- <!-- Configure the Jetty Server

-->

- <!-- ===============================================================

-->

- <Configure id="Server" class="org.mortbay.jetty.Server">

- <!-- ===========================================================

-->

- <!-- Server Thread Pool

-->

- <!-- ===========================================================

-->

- <Set name="ThreadPool">

- <New class="org.mortbay.thread.BoundedThreadPool">

<Set name="minThreads">10</Set>

<Set name="lowThreads">50</Set>

<Set name="maxThreads">250</Set>

</New>

</Set>

- <!-- ===========================================================

-->

- <!-- Set connectors

-->

- <!-- ===========================================================

-->

- <!-- One of each type!

-->

- <!-- ===========================================================

-->

- <!--

Use this connector for many frequently idle connections

and for threadless continuations.

-->

- <Call name="addConnector">

- <Arg>

- <New class="org.mortbay.jetty.nio.SelectChannelConnector">

- <Set name="port">

<SystemProperty name="jetty.port" default="8081" />

</Set>

<Set name="maxIdleTime">30000</Set>

<Set name="Acceptors">2</Set>

<Set name="confidentialPort">8443</Set>

</New>

</Arg>

</Call>

- <!-- ===========================================================

-->

- <!-- Set handler Collection Structure

-->

- <!-- ===========================================================

-->

- <Set name="handler">

- <New id="handlers" class="org.mortbay.jetty.handler.HandlerCollection">

- <Set name="handlers">

- <Array type="org.mortbay.jetty.Handler">

- <Item>

<New id="contexts" class="org.mortbay.jetty.handler.ContextHandlerCollection" />

</Item>

- <Item>

<New id="defaultHandler" class="org.mortbay.jetty.handler.DefaultHandler" />

</Item>

- <Item>

<New id="requestLog" class="org.mortbay.jetty.handler.RequestLogHandler" />

</Item>

</Array>

</Set>

</New>

</Set>

- <New id="TestContext" class="org.mortbay.jetty.webapp.WebAppContext">

- <Arg>

<Ref id="contexts" />

</Arg>

- <Arg>

<SystemProperty name="jetty.home" default="." />

/wwwroot

</Arg>

<Arg>/</Arg>

</New>

- <!-- ===========================================================

-->

- <!-- Discover contexts from webapps directory

-->

- <!-- ===========================================================

-->

- <Call class="org.mortbay.jetty.webapp.WebAppContext" name="addWebApplications">

- <Arg>

<Ref id="contexts" />

</Arg>

- <Arg>

<SystemProperty name="jetty.home" default="." />

/webapps

</Arg>

<Arg />

<Arg type="boolean">True</Arg>

- <!-- extract

-->

<Arg type="boolean">False</Arg>

- <!-- parent priority class loading

-->

</Call>

- <!-- ===========================================================

-->

- <!-- Configure Request Log

-->

- <!-- ===========================================================

-->

- <Ref id="requestLog">

- <Set name="requestLog">

- <New id="requestLogImpl" class="org.mortbay.jetty.NCSARequestLog">

- <Arg>

<SystemProperty name="jetty.logs" default="./jetty/logs" />

/yyyy_mm_dd.request.log

</Arg>

<Set name="retainDays">90</Set>

<Set name="append">true</Set>

<Set name="extended">false</Set>

<Set name="LogTimeZone">GMT</Set>

</New>

</Set>

</Ref>

- <!-- ===========================================================

-->

- <!-- extra options

-->

- <!-- ===========================================================

-->

<Set name="stopAtShutdown">true</Set>

- <!-- ensure/prevent Server: header being sent to browsers

-->

<Set name="sendServerVersion">true</Set>

</Configure>

Edited by daveed
Link to comment
Share on other sites

Hi,

I am trying to get a attribute so then the i can see what the defualt port.

Once i can get that value i then can add it to a text box an change it

like in

$var = _XMLGetAttrib('/tv/channel[@id="01"]/icon',"src")

for

<SystemProperty name="jetty.port" default="8081" />

default="8081"

could you show what i need to call here is the xml (snip);

You mean something like this?

;note untested - typed into forum post.
 $var = _XMLGetAttrib('//Configure/Call/Arg/New/Set/SystemProperty[@name="jetty.port"', "default")
Link to comment
Share on other sites

You mean something like this?

;note untested - typed into forum post.
 $var = _XMLGetAttrib('//Configure/Call/Arg/New/Set/SystemProperty[@name="jetty.port"', "default")
Thanks Eltorro thak worked for me :) ,

I am trying to replace attribute value for "default"

<SystemProperty name="jetty.port" default="8081" />

Using this: _XMLReplaceChild('/Configure/Call/Arg/New/Set/SystemProperty[@name="jetty.port"]', "SystemProperty")

Just clears clears both attributes and values

<SystemProperty name="" default="" />

How ca i replace the following value?

<SystemProperty name="jetty.port" default="xxxxx" />

Regards,

daveed

Edited by daveed
Link to comment
Share on other sites

  • 2 weeks later...

Hi all,

In my program, I want to extract all attribute values for all the nodes in an XML file.

There are many similar nodes with different attributes. It looks something like;

<root>

<node id=1 attrib="***">

<node id=2 attrib="***">

<node id=3 attrib="***">

<node id=4 attrib="***">

...

...

</root>

I thought _XMLGetAllAttrib should do the work. But when I digged into the source,

I found _XMLGetAllAttrib is doing something very strange. First, it gets all the nodes

objects with the specified node name by $objDoc.selectNodes, then it loops for each

node by "For $objNode In $objQueryNodes". Then gets the attributes array of the

current node by "$objNodeList = $objNode.attributes". So far it seems the function

is going to check all the attributes for each node one by one. However, for each new

node the function stores attributes to the same array variables, i.e. overwrite the $arrResponse

each time. As a result, only the attributes of the last node are returned. I don't understand

why the author does this. My workaround is to modify _XMLGetAllAttrib and store

all found attributes for each node with the same name into a 3D array and return it.

Any explanation?

Ting

Link to comment
Share on other sites

I would like to be able to parse an XML file that has several sections like the following:

<Songs_Database>
  <Song FilePath="D:\Folder\Album\Artist-Title-12.mp3" FileSize="4991051">
     <Display Author="Artist Name" Title="Track Title" Genre="Rock" Album="Album Name" Year="2000" Color="1492699" Cover="2050" Flag="23" />
     <Infos SongLength="9169920" FirstSeen="709041133" FirstPlay="709041133" LastPlay="709041133" PlayCount="1" Bitrate="192" Key="D m" />
     <Comment>Comment</Comment>
     <BPM Bpm="22368" Phase="13248" BeatPhase="3" />
     <FAME IsScanned="1" Volume="6490" />
     <Automix MixType="2" TempoStart="147456" TempoEnd="6589440" FadeStart="27648" FadeEnd="8989696" RealStart="0" RealEnd="9169408" />
  </Song>  
</Songs_Database>

I need to be able to display the various elements in several different ways using a GUI interface. The first task though is to get this data into at least an array (grid) so that I can navigate and manipulate the values. The issue becomes that not every entry will necessarily have all of these elements all the time.

Here is the smallest possible entry per item listed:

<Song FilePath="D:\Folder\Album\Artist-Title-12.mp3" FileSize="4991051">
  <Display Author="Artist Name" Title="Track Title" Color="1492699" Flag="23" />
  <Infos FirstSeen="709171043" />
</Song>

Not sure if it would be more prudent to parse and export to a CSV then read in the CSV or if going straight to an array would be the most effiecent.

Looking for any insight and love the potential that your wrapper can provide in this. If you need more information glad to share. And I know at this point it sounds a little vague.

Chris

Link to comment
Share on other sites

I would like to be able to parse an XML file that has several sections like the following:

<Songs_Database>
   <Song FilePath="D:\Folder\Album\Artist-Title-12.mp3" FileSize="4991051">
      <Display Author="Artist Name" Title="Track Title" Genre="Rock" Album="Album Name" Year="2000" Color="1492699" Cover="2050" Flag="23" />
      <Infos SongLength="9169920" FirstSeen="709041133" FirstPlay="709041133" LastPlay="709041133" PlayCount="1" Bitrate="192" Key="D m" />
      <Comment>Comment</Comment>
      <BPM Bpm="22368" Phase="13248" BeatPhase="3" />
      <FAME IsScanned="1" Volume="6490" />
      <Automix MixType="2" TempoStart="147456" TempoEnd="6589440" FadeStart="27648" FadeEnd="8989696" RealStart="0" RealEnd="9169408" />
   </Song>  
 </Songs_Database>

I need to be able to display the various elements in several different ways using a GUI interface. The first task though is to get this data into at least an array (grid) so that I can navigate and manipulate the values. The issue becomes that not every entry will necessarily have all of these elements all the time.

Here is the smallest possible entry per item listed:

<Song FilePath="D:\Folder\Album\Artist-Title-12.mp3" FileSize="4991051">
   <Display Author="Artist Name" Title="Track Title" Color="1492699" Flag="23" />
   <Infos FirstSeen="709171043" />
 </Song>

Not sure if it would be more prudent to parse and export to a CSV then read in the CSV or if going straight to an array would be the most effiecent.

Looking for any insight and love the potential that your wrapper can provide in this. If you need more information glad to share. And I know at this point it sounds a little vague.

Chris

I think I would parse the arrays returned from the xml into a multi-dimesional array that is setup like a "collection" of records . I think it would be easier than exporting to csv and then parsing the csv. Would It not be possible to just use the xml without going to an intermediate format?

Can you post what you have?

Edited by eltorro
Link to comment
Share on other sites

Can anyone give me hand on grabbing the driver guid's?

I tried this, but it only gives one guid and it's not in an array:

$avFields = _XMLGetAttrib ("//drivers/*", "guid")

See my original post HERE

<drivers>
<driver guid="{302cf53a-719d-4849-a4b3-0fc1751057c6}" enable="True">
<Name>NVIDIA Display nvdm.inf 7.15.10.9746</Name>
<Manufacturer>NVIDIA</Manufacturer>
<Version>7.15.10.9746</Version>
<Source>.\Out-of-box Drivers\Display\nvd 7.15.10.9746\nvdm.inf</Source>
<Type>Display</Type>
<Platform>x86</Platform>
<OSVersion>6.0</OSVersion>
<PNPId>PCI\VEN_10DE&DEV_00C8&SUBSYS_019C1028</PNPId>
<PNPId>PCI\VEN_10DE&DEV_00C9&SUBSYS_019C1028</PNPId>
<PNPId>PCI\VEN_10DE&DEV_00CC&SUBSYS_019B1028</PNPId>
<PNPId>PCI\VEN_10DE&DEV_0098&SUBSYS_019C1028</PNPId>
<PNPId>PCI\VEN_10DE&DEV_0099&SUBSYS_019C1028</PNPId>
<PNPId>PCI\VEN_10DE&DEV_0297&SUBSYS_019B1028</PNPId>
<PNPId>PCI\VEN_10DE&DEV_0298&SUBSYS_019B1028</PNPId>
<PNPId>PCI\VEN_10DE&DEV_0299&SUBSYS_019B1028</PNPId>
<PNPId>PCI\VEN_10DE&DEV_029A&SUBSYS_019B1028</PNPId>
<PNPId>PCI\VEN_10DE&DEV_029B&SUBSYS_019B1028</PNPId>
<PNPId>PCI\VEN_10DE&DEV_029D&SUBSYS_019B1028</PNPId>
<PNPId>PCI\VEN_10DE&DEV_01D7&SUBSYS_01C21028</PNPId>
<PNPId>PCI\VEN_10DE&DEV_01D7&SUBSYS_01CC1028</PNPId>
<PNPId>PCI\VEN_10DE&DEV_01D7&SUBSYS_20031028</PNPId>
<PNPId>PCI\VEN_10DE&DEV_01D8&SUBSYS_01CC1028</PNPId>
<PNPId>PCI\VEN_10DE&DEV_01D8&SUBSYS_01D71028</PNPId>
<PNPId>PCI\VEN_10DE&DEV_01DC&SUBSYS_01C81028</PNPId>
</driver>
<driver guid="{8e05109c-bf13-40fb-b653-da98547e5e30}" enable="True">
<Name>NVIDIA Display nvdm.inf 7.15.10.9746</Name>
<Manufacturer>NVIDIA</Manufacturer>
<Version>7.15.10.9746</Version>
<Source>.\Out-of-box Drivers\Display\nvd 7.15.10.9746 (1)\nvdm.inf</Source>
<Type>Display</Type>
<Platform>x86</Platform>
<OSVersion>6.0</OSVersion>
<PNPId>PCI\VEN_10DE&DEV_00C8&SUBSYS_019C1028</PNPId>
<PNPId>PCI\VEN_10DE&DEV_00C9&SUBSYS_019C1028</PNPId>
<PNPId>PCI\VEN_10DE&DEV_00CC&SUBSYS_019B1028</PNPId>
<PNPId>PCI\VEN_10DE&DEV_0098&SUBSYS_019C1028</PNPId>
<PNPId>PCI\VEN_10DE&DEV_0099&SUBSYS_019C1028</PNPId>
<PNPId>PCI\VEN_10DE&DEV_0297&SUBSYS_019B1028</PNPId>
<PNPId>PCI\VEN_10DE&DEV_0298&SUBSYS_019B1028</PNPId>
<PNPId>PCI\VEN_10DE&DEV_0299&SUBSYS_019B1028</PNPId>
<PNPId>PCI\VEN_10DE&DEV_029A&SUBSYS_019B1028</PNPId>
<PNPId>PCI\VEN_10DE&DEV_029B&SUBSYS_019B1028</PNPId>
<PNPId>PCI\VEN_10DE&DEV_029D&SUBSYS_019B1028</PNPId>
<PNPId>PCI\VEN_10DE&DEV_01D7&SUBSYS_01C21028</PNPId>
<PNPId>PCI\VEN_10DE&DEV_01D7&SUBSYS_01CC1028</PNPId>
<PNPId>PCI\VEN_10DE&DEV_01D7&SUBSYS_20031028</PNPId>
<PNPId>PCI\VEN_10DE&DEV_01D8&SUBSYS_01CC1028</PNPId>
<PNPId>PCI\VEN_10DE&DEV_01D8&SUBSYS_01D71028</PNPId>
<PNPId>PCI\VEN_10DE&DEV_01DC&SUBSYS_01C81028</PNPId>
</driver>
</drivers>
Link to comment
Share on other sites

Ok, so I found my own answer. I found this and adapted it to my situation:

Func Main()
    Local $szXPath, $aNodeName, $find, $ns, $oXSD,$iNodeCount,$aAttrName[1],$aAttrVal[1],$ret_val
    $xmlFile = "C:\Documents and Settings\jmascote\My Documents\!!AUTOIT Scripts\BDD2007\Drivers.xml"
    $ns = ""
    $oXSD = _XMLFileOpen ($xmlFile, $ns)
    If @error Or $oXSD < 1 Then
        MsgBox(0, "Error", "There was an error opening the file " & $xmlFile)
        $oXSD = 0
        Exit
    EndIf
    $szXPath = "//drivers"
    $iNodeCount = _XMLGetNodeCount($szXPath & "/*")
    MsgBox(0,"Node Count",$iNodeCount)

    $aNodeName = _XMLGetChildNodes ($szXPath); get a list of node names under this path
    If $aNodeName <> - 1 Then
        For $find = 1 To $aNodeName[0]
            ConsoleWrite($aNodeName[$find]& '[' & $find & ']'&@LF)
          ;It's better to use node index instead of node name as all node here have same name.
          _XMLGetAllAttrib($szXPath & "/*" & '[' & $find & ']',$aAttrName,$aAttrVal)
            _ArrayDisplay($aAttrName,$szXPath & "/*" & '[' & $find & ']')
            _ArrayDisplay($aAttrVal,$szXPath & "/*" & '[' & $find & ']')
            

        Next
        MsgBox(266288,"_XMLWrapper","Done")
    Else
        MsgBox(0, "Error:", "No nodes found for " & $szXPath)
    EndIf
    $oXSD = 0
EndFunc
Link to comment
Share on other sites

  • 1 month later...

Hello out there.

I've got some errors coming up and I am unsure as to why they are coming up. I'm trying to use the MDI version of the XMLDOM file, and it's erroring out on me.

Here is the Error message:

_XMLMdiDOM.au3 (276) : ==> Array variable subscript badly formatted.: 
ReDim $objDoc[$oIndex] 
ReDim $objDoc[^ ERROR

Here is the Code I'm trying to run that is making that error message:

#include <_XMLMdiDOM.au3>

Const $FileUsers = 0
Const $FileNameUsers = @ScriptDir & "\Users.xml"
Const $FileOrganizations = 1
Const $FileNameOrganizations = @ScriptDir & "\Organizations.xml"
Const $FileMemberType = 2
Const $FileNameMemberType = @ScriptDir & "\MemberTypes.xml"
Const $FileGroups = 3
Const $FileNameGroups = @ScriptDir & "\Groups.xml"
Const $FileRoles = 4
Const $FileNameRoles = @ScriptDir & "\Roles.xml"

$ATTRIBS = _ArrayCreate ("name")

If Not FileExists($FileNameUsers) Then
    _XMLCreateFile($FileNameUsers, "users", False, $FileUsers)
EndIf
_XMLFileOpen($FileNameUsers, "", $FileUsers)

If Not FileExists($FileNameOrganizations) Then
    _XMLCreateFile($FileNameOrganizations, "organizations", False, $FileOrganizations)
EndIf
_XMLFileOpen($FileNameOrganizations, "", $FileOrganizations)

If Not FileExists($FileNameMemberType) Then
    _XMLCreateFile($FileNameMemberType, "membertypes", False, $FileMemberType)
EndIf
_XMLFileOpen($FileNameMemberType, "", $FileMemberType)

If Not FileExists($FileNameGroups) Then
    _XMLCreateFile($FileNameGroups, "groups", False, $FileGroups)
EndIf
_XMLFileOpen($FileNameGroups, "", $FileGroups)

If Not FileExists($FileNameRoles) Then
    _XMLCreateFile($FileNameRoles, "roles", False, $FileRoles)
EndIf
_XMLFileOpen($FileNameRoles, "", $FileRoles)

I'm running 3.2.4.9 if that helps any.

Any Help would be greatly appreciated.

Link to comment
Share on other sites

Hey guys, I've been trying to get this to work for a while now

This is my script and the xml, please let me know what I'm doing wrong here.

Thanks in advance

#include "_XMLDomWrapper.au3"
$xml = _XMLFileOpen( @ScriptDir&"\savage garden.xml" )
$node = _XMLGetValue("//playlist/trackList/track/location[1]")
ConsoleWrite($node)

<playlist version="1" start="0" end="9" total="142" prev="None" next="10">
<title><title/>
<trackList>
<track>
<location>
http://espanol.geocities.com/neto3033/mp3/Savage_Garden_-_Break_me_shake_me.mp3
</location>
<title>Break Me Shake Me</title>
<creator>Savage Garden</creator>
<album>Savage Garden</album>
<genre>Pop</genre>
<composer/>
ETC...
Edited by CyberZeroCool
Check out ConsultingJoe.com
Link to comment
Share on other sites

Hey guys, I've been trying to get this to work for a while now

This is my script and the xml, please let me know what I'm doing wrong here.

Thanks in advance

#include "_XMLDomWrapper.au3"
$xml = _XMLFileOpen( @ScriptDir&"\savage garden.xml" )
$node = _XMLGetValue("//playlist/trackList/track/location[1]")
ConsoleWrite($node)oÝ÷ ÙÊ{­)¬¥Ëoz»

<playlist version="1" start="0" end="9" total="142" prev="None" next="10">
  <title>
    <trackList>
      <track>
        <location>
        http://espanol.geocities.com/neto3033/mp3/Savage_Garden_-_Break_me_shake_me.mp3</location>
        <title>Break Me Shake Me</title>
        <creator>Savage Garden</creator>
        <album>Savage Garden</album>
        <genre>Pop</genre>
        <composer />
      </track>
    </trackList>
  </title>
</playlist>
Link to comment
Share on other sites

  • 1 month later...

Hey, i'm having problems to getting anything to work... I have done just like in the example (but simpler)... take a look:

The script:

#Include <_XMLDomWrapper.au3>

$xml = _XMLFileOpen (@ScriptDir & "config.xml")

While 1     
    msgbox(0,"1",_XMLGetValue("/Settings/1"))
    sleep(1000)
WEnd

..and the xml (config.xml):

<?xml version="1.0" encoding="UTF-16"?>
   <Settings>
      <1>10</1>
   </Settings>

Thank you for helping me :)

Link to comment
Share on other sites

Hey, i'm having problems to getting anything to work... I have done just like in the example (but simpler)... take a look:

The script:

#Include <_XMLDomWrapper.au3>
  
  $xml = _XMLFileOpen (@ScriptDir & "config.xml")
  
  While 1       
      msgbox(0,"1",_XMLGetValue("/Settings/1"))
      sleep(1000)
  WEnd

..and the xml (config.xml):

<?xml version="1.0" encoding="UTF-16"?>
     <Settings>
        <1>10</1>
     </Settings>

Thank you for helping me :)

Maybe

$xml = _XMLFileOpen (@ScriptDir & "\config.xml")

Well, that was just a start.

in the xml, the node cannot be a number.

Also the xml specifies UFT-16 encoding so the xml must be saved as unicode.

here's a working script and xml.

#Include <_XMLDomWrapper.au3>

$xml = _XMLFileOpen (@ScriptDir & "\test.xml")
If @error Then Exit
$a = _XMLGetValue("/Settings/a")
msgbox(0,"1",$a[1])
sleep(1000)

<?xml version="1.0" encoding="UTF-16"?>
    <Settings>
       <a>10</a>
    </Settings>
Edited by eltorro
Link to comment
Share on other sites

Also add: _SetDebug(True)

this reveals:

Error opening specified file: C:\...\config.xml

Switch from current encoding to specified encoding not supported.

Dale

eltorro, I'm anxious to dig into your UDF... haven't done much with it yet...

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

hehe, thank you, it worked :)

Well, i think it's obvious than I'm new to the XML-thing... till now I have just used ini-files, but they aren't easily adaptable to other platforms... so thats why I have started on this!

Another question: I saw the command "_XMLGetFirstValue" in the au3 file uploaded with the include. Will this enable me to, instead of using "$a = _XMLGetValue" and then "$a[1]", to get the same value??? An how would I do it??? Cuz' now it keeps telling me that "_XMLGetFirstValue" is an undefined function...

#Include <_XMLDomWrapper.au3>

Dim $a

_SetDebug(True)

$xml = _XMLFileOpen (@ScriptDir & "\config.xml")

If @error Then Exit

        $a =_XMLGetFirstValue("/Settings/a")

While 1

    sleep(1000)
    
    msgbox(0,"a",$a)
    
WEnd

Even if I can't it's still a GREAT job you have done, implementing the possibility of using XML in AutoIt ^_^ thx

Edited by some1
Link to comment
Share on other sites

Another question: I saw the command "_XMLGetFirstValue" in the au3 file uploaded with the include. Will this enable me to, instead of using "$a = _XMLGetValue" and then "$a[1]", to get the same value??? An how would I do it??? Cuz' now it keeps telling me that "_XMLGetFirstValue" is an undefined function...

I don't remember that being a part of the wrapper, in fact a quick search of the UDF returns no result. However, you could implement it as such:

Func _XMLGetFirstValue($strXPath)
     Local $vFirstValue = _XMLGetValue($strXPath)
     If @error Then Return SetError(@error,0,0)
     Return $vFirstValue[1]
 EndIfoÝ÷ Ù8^*.r¥v·©§¶0±µV¥¹çîËb¢w"¶­jëh×6 #Include <_XMLDomWrapper.au3>

Dim $a

_SetDebug(True)

$xml = _XMLFileOpen (@ScriptDir & "\config.xml")

If @error Then Exit

        $a =_XMLGetFirstValue("/Settings/a")

While 1

    sleep(1000)
    
    msgbox(0,"a",$a)
    
WEnd
 
 Func _XMLGetFirstValue($strXPath)
      Local $vFirstValue = _XMLGetValue($strXPath)
      If @error Then Return SetError(@error,0,0)
      Return $vFirstValue[1]
  EndIf

Give it a try.

Quick question, why the msgbox in a endless loop?

Link to comment
Share on other sites

Well thats cool... I have never made or edited any addition for AutoIt, but this worked instantly... cool :)

I asked about the "_XMLGetFirstValue" bacause I saw it in the "XMLexample.au3" you had uploaded (I later found out it was called "_GetFirstValue" (without "XML"):

Func LoadSettings()
    Local $sFile = @ScriptFullPath & ".xml"
    If FileExists($sFile) Then
            $ret = _XMLFileOpen ($sFile)
            if $ret =0 then Exit
            WinMove("Sample GUI", "",_XMLGetAttrib ("/Settings/Position", "x"), _
                                    _XMLGetAttrib ("/Settings/Position", "y"), _
                                    _XMLGetAttrib ("/Settings/Position", "w"), _
                                    _XMLGetAttrib ("/Settings/Position", "h")) 
            WinSetState("Sample GUI", "",_GetFirstValue("/Settings/State"))
            GUICtrlSetData($h_Edit, _GetFirstValue("/Settings/Edit"))
            GUICtrlSendMsg($h_tabcontrol, 0x1300 + 12, Int(_GetFirstValue("/Settings/Tab")), 0)
            GUICtrlSendMsg($h_List, 0x0186, Int(_GetFirstValue("/Settings/List")), 0)
            ControlListView("Sample GUI", "", $listView, "Select", Int(_GetFirstValue("/Settings/ListView")), Int(_GetFirstValue("/Settings/ListView")))
            GUICtrlSetState($h_Radio1, _GetFirstValue("/Settings/Radio1"))
            GUICtrlSetState($h_Radio2, _GetFirstValue("/Settings/Radio2"))
            GUICtrlSetData($h_UpDown, _GetFirstValue("/Settings/UpDown"))
            GUICtrlSetData($h_Slider, _GetFirstValue("/Settings/Slider"))
            GUICtrlSetData($h_Input, _GetFirstValue("/Settings/Input"))
            GUICtrlSetState($h_Check,_GetFirstValue( "/Settings/Check"))
            GUICtrlSetState( _GetFirstValue("/Settings/Tv1"), $GUI_FOCUS)
            GUICtrlSetState(_GetFirstValue("/Settings/Tv2"), $GUI_FOCUS)
            For $x = 1 to UBound($tvtwo)-1
                GUICtrlSetState($tvtwo[$x],_GetFirstValue("/Settings/Tv2/tvtwo"&$x))
            Next
            Return 1
    EndIf
    Return 0    
EndFunc  ;==>LoadSettings

About the msgbox.. I just saw it as the easiest solution when testing the wrapper.. I rarely think far ahead xD

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...