Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

_XMLGetAttrib


  • Please log in to reply
9 replies to this topic

#1 Romm

Romm

    Wayfarer

  • Active Members
  • Pip
  • 97 posts

Posted 12 January 2008 - 06:37 PM

'//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, 12 January 2008 - 06:38 PM.








#2 weaponx

weaponx

    I'm coming for blood, no code of conduct, no law.

  • MVPs
  • 5,366 posts

Posted 12 January 2008 - 07:19 PM

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, 12 January 2008 - 07:23 PM.


#3 Romm

Romm

    Wayfarer

  • Active Members
  • Pip
  • 97 posts

Posted 12 January 2008 - 07:52 PM

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....

#4 weaponx

weaponx

    I'm coming for blood, no code of conduct, no law.

  • MVPs
  • 5,366 posts

Posted 12 January 2008 - 08:48 PM

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, 12 January 2008 - 08:49 PM.


#5 Romm

Romm

    Wayfarer

  • Active Members
  • Pip
  • 97 posts

Posted 13 January 2008 - 02:15 AM

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

#6 weaponx

weaponx

    I'm coming for blood, no code of conduct, no law.

  • MVPs
  • 5,366 posts

Posted 13 January 2008 - 05:17 AM

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

#7 Romm

Romm

    Wayfarer

  • Active Members
  • Pip
  • 97 posts

Posted 13 January 2008 - 11:28 AM

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("<a href='http://www.com' class='bbc_url' title='External link' rel='nofollow external'>http://www.com"</a>)


I got COM Error with DOM!
err.number is: 800040005
err.lastdllerror is: 1008
err.scriptline is: 201

#8 Romm

Romm

    Wayfarer

  • Active Members
  • Pip
  • 97 posts

Posted 13 January 2008 - 02:16 PM

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

My script:
While 1 $IE_Conf = _IECreate("<a href='http://3k.mail.ru/hunt_conf.php' class='bbc_url' title='External link' rel='nofollow external'>http://3k.mail.ru/hunt_conf.php"</a>, 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, "<a href='http://3k.mail.ru/hunt_conf.php?mode=farm&action=check&num=' class='bbc_url' title='External link' rel='nofollow external'>http://3k.mail.ru/hunt_conf.php?mode=farm&action=check&num="</a> & $num)     Sleep(25000)     EndIf If $num = -1 Then     Sleep(6000) EndIf _IEAction ($IE_Conf,"quit") Wend

Edited by Romm, 13 January 2008 - 04:29 PM.


#9 weaponx

weaponx

    I'm coming for blood, no code of conduct, no law.

  • MVPs
  • 5,366 posts

Posted 13 January 2008 - 09:10 PM

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

#10 Romm

Romm

    Wayfarer

  • Active Members
  • Pip
  • 97 posts

Posted 13 January 2008 - 09:20 PM

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, 13 January 2008 - 10:26 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users