Jump to content

Recommended Posts

Posted

Here is xml...

<?xml version="1.0" encoding="utf-8" ?> 
- <hunt>
- <bots>
  <bot id="3162125" name="A" level="3" pic="tks_snegnik_2_small.gif" sk="2015" agrlevel="0" x="1001" y="459" fight_id="0" /> 
  <bot id="7994" name="B" level="2" pic="jakal_small.jpg" sk="2000" agrlevel="20" x="856" y="520" fight_id="0" /> 
  <bot id="2812381" name="C" level="1" pic="jakal_small.jpg" sk="2000" agrlevel="0" x="920" y="520" fight_id="0" /> 
  <bot id="1061863" name="D" level="2" pic="ris_small.jpg" sk="2005" agrlevel="20" x="915" y="1228" fight_id="0" />

I want to make script that will search by name.

1) Search A

2.1) If fight_id value = 0 Then

$level = " get level value of A"

$id = " get bot id value of A"

($level = 3, $id = 3162125)

2.2) If fight_id value <>0 Then

....

Can somebody help me? I dont think that it is posible...but maybe...

This script will search into web browser....

Posted (edited)

i still cant understand how i cant get "level" value from this.

<bot id="3554662" name="AAA" level="1" pic="jakal_small.jpg" sk="2000" agrlevel="0" x="1411" y="1149" fight_id="0" />

if something like <a>5</a> all is ok...

_GetFirstValue

Edited by Romm
Posted (edited)

Merry X-Mas...

#include <_XMLDomWrapper.au3>
#include <Array.au3>

$sXMLFile = "test3.xml"

$result = _XMLFileOpen($sXMLFile)
if $result = 0 then Exit

$sXPath = '//bots/bot[@name = "A"]'

$fight_id = _XMLGetAttrib ($sXPath, "fight_id")
If @Error Then MsgBox(0,"","Name not found")

If $fight_id = 0 Then
    ;Do stuff
Else
    ;Do other stuff
EndIf

test3.xml:

<?xml version="1.0" encoding="utf-8"?>
  <hunt>
    <bots>
      <bot id="3162125" name="A" level="3" pic="tks_snegnik_2_small.gif" sk="2015" agrlevel="0" x="1001" y="459" fight_id="0" />
      <bot id="7994" name="B" level="2" pic="jakal_small.jpg" sk="2000" agrlevel="20" x="856" y="520" fight_id="0" />
      <bot id="2812381" name="C" level="1" pic="jakal_small.jpg" sk="2000" agrlevel="0" x="920" y="520" fight_id="0" />
      <bot id="1061863" name="D" level="2" pic="ris_small.jpg" sk="2005" agrlevel="20" x="915" y="1228" fight_id="0" />
    </bots>
  </hunt>
Edited by weaponx
Posted

now another problem

XML file is written "inside" .php.

hunt_conf.php... But when you open it, you see XML...

How to load this XML? I tried _IEBodyReadText, InetGet, but it is imposible to make xml...

Posted

Ok only idea i have

$IE_Conf = _IECreate("http://3k.mail.ru/hunt_conf.php", 1, 0)
$c = _IEBodyReadText ($IE_Conf)
FileWrite ("test2.txt", $c)
$d = FileReadLine("test2.txt", 5)

But how to insert this line to xml???

Posted

If the PHP script is generating straight XML, you can use this:

#include <INet.au3>

$XML = _INetGetSource ( $s_URL )

Posted (edited)

OK if i use:

$IE_Conf = _IECreate("http://3k.mail.ru/hunt_conf.php", 1, 0)
$A = _IEBodyReadText ($IE_Conf)
MsgBox(1, "", $A)

I got XML...but like a text and i cant use it...

If i use

$XML = _INetGetSource ("http://3k.mail.ru/hunt_conf.php")
MsgBox(1, "", $XML)

I got:

<scipt>top.location.href="index.php";</script>

Edited by Romm
Posted

OK if i use:

$IE_Conf = _IECreate("http://3k.mail.ru/hunt_conf.php", 1, 0)
$A = _IEBodyReadText ($IE_Conf)
MsgBox(1, "", $A)

I got XML...but like a text and i cant use it...

If i use

$XML = _INetGetSource ("http://3k.mail.ru/hunt_conf.php")
MsgBox(1, "", $XML)

I got:

<scipt>top.location.href="index.php";</script>

Then use the first one... I don't see the problem. Just combine the first one with the code posted above. Then either save the source to a temporary file, and just label it .xml even though it won't matter whether it be txt or xml or whatever else. Then use the code above, change the location of the XMLFileOpen and you should be good to go.
Posted (edited)

Uhh another problem...if for example @name = "word in NON English language" (russian) i always get an error :D

Is is posible to delete all @name from file?

Ah... ok done...

_ReplaceStringInFile ("test2.txt", "ss", "dd", 1, 1) :P

Edited by Romm

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
×
×
  • Create New...