Sign in to follow this  
Followers 0

_XMLGetAttrib

10 posts in this topic

Posted (edited)

'//bots/bot[@level= "3"]' I use this for <bots>

'//farm/item[@prof= "1"]' And this for <farm>... But last one doesnt work :D

<?xml version="1.0" encoding="utf-8" ?> 
- <hunt>
- <bots>
  <bot id="3162125" name="Monster" level="3" pic="tks_snegnik_2_small.gif" sk="2015" agrlevel="0" x="1368" y="1142" fight_id="27308293" /> 
  <bot id="7994" name="Monster" level="2" pic="jakal_small.jpg" sk="2000" agrlevel="20" x="1399" y="461" fight_id="0" /> 
  <bot id="2812381" name="Monster" level="1" pic="jakal_small.jpg" sk="2000" agrlevel="0" x="638" y="1139" fight_id="0" /> 
</bots>
- <farm>
  <item num="10" name="Gather" pic="m-glocinia.gif" swf="tks_prof_trav_glocinia.swf" prof="1" quality="0" skill="1" artikul_id="311" x="66" y="1152" farming="0" /> 
  <item num="22" name="Gather" pic="m-karas.gif" swf="fish_blue.swf" prof="4" quality="0" skill="1" artikul_id="334" x="662" y="389" farming="1" /> 
  <item num="44" name="Gather" pic="m-paslen.gif" swf="tks_prof_trav_paslen.swf" prof="1" quality="0" skill="1" artikul_id="312" x="96" y="1023" farming="0" /> 
  <item num="53" name="Gather" pic="m-okun.gif" swf="fish_blue.swf" prof="4" quality="0" skill="1" artikul_id="816" x="923" y="356" farming="5" /> 
  </farm>
  </hunt>
Edited by Romm

Share this post


Link to post
Share on other sites



Posted (edited)

You can't use it like that.

'//bots/bot[@level= "3"]' is a 1 to 1 match

'//farm/item[@prof= "1"]' is a 1 to many match

You need to match to a unique attribute.

See here for XPATH usage:

http://www.w3schools.com/xpath/default.asp

Edited by weaponx

Share this post


Link to post
Share on other sites

Posted

Hmmm very strange because when i use

$sXPath = '//bots/bot[@level="3"]'

$num = _XMLGetAttrib ($sXPath, "id")
MsgBox(1, "", $num)

<?xml version="1.0"?>
  <hunt>
 <bots>
  <bot id="3902717" name="TayushiySneshnik" level="3" pic="tks_snegnik_2_small.gif" sk="2015" agrlevel="0" x="730" y="1224" fight_id="0" /> 
  <bot id="3458759" name="TayushiySneshnik" level="3" pic="tks_snegnik_2_small.gif" sk="2015" agrlevel="0" x="1016" y="741" fight_id="0" /> 
  <bot id="3902716" name="TayushiySneshnik" level="3" pic="tks_snegnik_2_small.gif" sk="2015" agrlevel="0" x="524" y="1122" fight_id="0" /> 
  <bot id="3902715" name="TayushiySneshnik" level="3" pic="tks_snegnik_2_small.gif" sk="2015" agrlevel="0" x="906" y="1230" fight_id="27249307" /> 
  <bot id="3902714" name="TayushiySneshnik" level="3" pic="tks_snegnik_2_small.gif" sk="2015" agrlevel="0" x="1189" y="577" fight_id="27249924" /> 
 </bots>
  </hunt>

All is ok....

Share this post


Link to post
Share on other sites

Posted (edited)

Well you never said which attribute you are trying to get. In the first example you were trying to get the fight_id.

Edited by weaponx

Share this post


Link to post
Share on other sites

Posted

i need id attribute when fight_id =0, level = 3, sk = 2015

Share this post


Link to post
Share on other sites

Posted

i need id attribute when fight_id =0, level = 3, sk = 2015

I thought you were trying to get attributes from the "item" nodes, these are only in the "bot" nodes. You need to be very specific when working with something like XML. Moving along...

Here is how you retrieve an attribute based on multiple matching attributes:

$sXPath = '//bots/bot[@fight_id = "0" and @level = "3" and @sk = "2015"]'

This would be similar to SQL:

SELECT id FROM bots WHERE fight_id = 0 AND level = 3 AND sk = 2015

Share this post


Link to post
Share on other sites

Posted

Ok all is fine now (error was because _IEBodyReadText added space before <?xml version="1.0" encoding="utf-8" ?> )

But now when:

$sXMLFile = "form.txt"
$result = _XMLFileOpen($sXMLFile)
if $result = 0 then Exit
$sXPath = '//farm/item[@prof = "1" and @skill = "1" and @farming = "0"]'
$num = _XMLGetAttrib ($sXPath, "num")

_IECreate("http://www.com")

I got COM Error with DOM!

err.number is: 800040005

err.lastdllerror is: 1008

err.scriptline is: 201

Share this post


Link to post
Share on other sites

Posted (edited)

Hmmm all works fine for me, except this popup error window :D

My script:

While 1
$IE_Conf = _IECreate("http://3k.mail.ru/hunt_conf.php", 0, 0)
FileDelete("form.txt")
$c = _IEBodyReadText($IE_Conf)
FileWrite ("form.txt", $c)
$sXMLFile = "form.txt"
$result = _XMLFileOpen($sXMLFile)
if $result = 0 then Exit
$sXPath = '//farm/item[@prof = "1" and @skill = "1" and @farming = "0"]'
$num = _XMLGetAttrib ($sXPath, "num")

If $num >= 0 Then
    _IENavigate($IE_Conf, "http://3k.mail.ru/hunt_conf.php?mode=farm&action=check&num=" & $num)
    Sleep(25000)
    EndIf
If $num = -1 Then
    Sleep(6000)
EndIf
_IEAction ($IE_Conf,"quit")
Wend
Edited by Romm

Share this post


Link to post
Share on other sites

Posted

You do not give enough information. What does the error window say?

Share this post


Link to post
Share on other sites

Posted (edited)

COM ERROR WITH DOM!

err.description is:
err.windescription: Unknown Error

err.number is: 80020009
err.lastdllerror is: 0
err.scriptline is: 4149
err.source is:
err.helpfile is:
err.helpcontext is: 0

I just want to skip error cose all works fine

And after 20-30 min of running my script i got:

C:\Program Files\AutoIt3\Include\_XMLDomWrapper.au3 (176) : ==> The requested action with this object has failed.:

$objDoc.Load ($strFile)

$objDoc.Load ($strFile)^ ERROR

:D

Edited by Romm

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

  • Recently Browsing   0 members

    No registered users viewing this page.