Jump to content
Sign in to follow this  
Romm

Problems with XML...very hard...

Recommended Posts

Romm

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

Share this post


Link to post
Share on other sites
Romm

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

Share this post


Link to post
Share on other sites
weaponx

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

Share this post


Link to post
Share on other sites
weaponx

Name not found :)

I tested it like 9 times. It works fine. Did you use your own xml or mine?

Share this post


Link to post
Share on other sites
Romm

all is ok now

Edited by Romm

Share this post


Link to post
Share on other sites
Romm

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

Share this post


Link to post
Share on other sites
Romm

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

Share this post


Link to post
Share on other sites
weaponx

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

#include <INet.au3>

$XML = _INetGetSource ( $s_URL )

Share this post


Link to post
Share on other sites
Romm

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

Share this post


Link to post
Share on other sites
Thatsgreat2345

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.

Share this post


Link to post
Share on other sites
Romm

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

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.