Sign in to follow this  
Followers 0
shaqan

[Solved] XML attribute value

2 posts in this topic

#1 ·  Posted (edited)

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"
_XMLFileOpen($file1)
If @error Then
ConsoleWrite("Sample.xml " & _XMLError("") & @CRLF)
Exit
EndIf
$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] & "]")
  next
ConsoleWrite(@CRLF)
Next

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">
   <Skills>
      <Skill Name="Accurate Eye" Category="Physical" Obtained="2010-03-14 01:43:18">
         <Status>Active</Status>
         <StageCurrent>5</StageCurrent>
         <StageProgress>45%</StageProgress>
         <StageActivated>5</StageActivated>
         <LastGain>2011-12-08 02:52:26</LastGain>
      </Skill>
      <Skill Name="Weaponry" Category="Combat" Obtained="2010-03-14 01:43:22">
         <Status>Active</Status>
         <StageCurrent>4</StageCurrent>
         <StageProgress>93%</StageProgress>
         <StageActivated>5</StageActivated>
         <LastGain>2011-12-08 03:07:09</LastGain>
      </Skill>
      <Skill Name="Zoology" Category="Science" Obtained="2010-03-31 03:05:19">
         <Status>Active</Status>
         <StageCurrent>0</StageCurrent>
         <StageProgress>23%</StageProgress>
         <StageActivated>0</StageActivated>
         <LastGain>2011-05-25 02:59:34</LastGain>
      </Skill>
   </Skills>
</Data>

(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  
Followers 0