Jump to content
Sign in to follow this  

[Solved] XML attribute value

Recommended Posts


I would love some assistance..

EDIT: Managed to find a way _XMLGetAttrib would work but it also created another problem. Now only very last skill attribute in node is parsed at all times. How to fix this?

So far ready Autoit3 code looks like this (relied on examples in forum)..

#include <Array.au3>
#include <_XMLDomWrapper.au3>
Local $file1 = @ScriptDir & "\sample.xml"
If @error Then
ConsoleWrite("Sample.xml " & _XMLError("") & @CRLF)
$xpath = "//Data/Skills"
$Nodes = _XMLGetChildNodes($xpath)
for $i = 1 to UBound($Nodes) -1
;----Problem child-------------[SOLVED]------------------------
$a =  _XMLGetAttrib("/Data/Skills/Skill[" & $i & "]", "Name")
ConsoleWrite( $Nodes[$i] & "[" & $a & "]" & @CRLF )
$sNodes = _XMLGetChildNodes($xpath & "/" & $Nodes[$i])
  for $j = 1 to UBound( $sNodes ) - 1
  $sNode_Values = _XMLGetValue($xpath & "/*[" & $i & "]/" & $sNodes[$j])
        If IsArray($sNode_Values) Then $sValue = $sNode_Values[1]
   ConsoleWrite( " " & $sNodes[$j] & "," & "[" & $sNode_Values[1] & "]")

and I would like to get output like this (in Scite console)

Skill[Accurate Eye]
Status,[Active] StageCurrent,[5] StageProgress,[45%] StageActivated,[5] LastGain,[2011-12-08 02:52:26]

xml file looks (simplified to show just relevant portion of it) like this

<Data Type="Skills" Version="0.4b" CitizenshipID="F714-874F">
      <Skill Name="Accurate Eye" Category="Physical" Obtained="2010-03-14 01:43:18">
         <LastGain>2011-12-08 02:52:26</LastGain>
      <Skill Name="Weaponry" Category="Combat" Obtained="2010-03-14 01:43:22">
         <LastGain>2011-12-08 03:07:09</LastGain>
      <Skill Name="Zoology" Category="Science" Obtained="2010-03-31 03:05:19">
         <LastGain>2011-05-25 02:59:34</LastGain>

(Trying to eventually create a tool which would allow me to measure skillgains between skilling runs. Asking this should be OK by Forum rules (checked and could not find anything that forbade it) since its not for game automation. Just using XML files which are legally exported from game (AfterWorld:Alpha) by using its UI.)

EDIT No2. Left working modification into post. Might be helpful for the next guy messing around with _XMLGetAttrib (_XMLDomWrapper.au3 I used was old year 2008 version)

Edited by shaqan

Share this post

Link to post
Share on other sites

thanks, it worked me this solution.

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