Jump to content

Parsing XML..need help


RunDLC
 Share

Recommended Posts

Global $oXML = ObjCreate("Microsoft.XMLHTTP")
$oXML.Open("GET", "http://db.tigsource.com/games/cave-story.xml", 0)
$oXML.Send

Global $sFile = "test.xml"
FileWrite($sFile, $oXML.responseText)


If _XMLFileOpen($sFile) Then
    Local $sLvl = _XMLGetValue("/game/average-rating")
    msgbox(0,"",$sLvl)
EndIf

i am trying to get date from this xml file

<?xml version="1.0" encoding="UTF-8" ?> 
- <game>
  <average-rating>4.7</average-rating> 
  <code-license>Closed source</code-license> 
  <content-license>Unlicensed</content-license> 
  <created-at type="datetime">2008-03-23T09:23:47+00:00</created-at> 
  <description>Cave Story (Dōkutsu Monogatari) is a freeware videogame released in 2004 for PC, designed and created over five years. The game is a traditional action-adventure game, reminiscent of the Castlevania and Metroid games. It has been fan-translated to English by Aeon Genesis.</description> 
  <developer-id type="integer">5</developer-id> 
  <expected-release nil="true" /> 
  <id type="integer">6</id> 
  <is-multiplayer type="boolean">false</is-multiplayer> 
  <is-singleplayer type="boolean">true</is-singleplayer> 
  <last-release-at type="date" nil="true" /> 
  <name>Cave Story</name> 
  <price nil="true" /> 
  <rating-count type="integer">366</rating-count> 
  <released-in type="date">2004-12-01</released-in> 
  <review-count type="integer">89</review-count> 
  <shortname>cave-story</shortname> 
  <updated-at type="datetime">2010-10-19T02:02:56+00:00</updated-at> 
- <reviews type="array">
- <review>
  <body>This is an indie effort akin to Pulp Fiction or Velvet Underground in that it has inspired many ambitious developers to make their own games, often in its style. And with reason. It’s good—with a sprawling amount of content, combining elements from platformers like Metroid and the Wonder Boy series, with some role playing elements and a cute story. Very impressive considering the entire thing was done by one guy: engine, content, graphics, and music. If you haven’t played it, consider it an essential.</body> 
  <created-at type="datetime">2008-07-02T00:42:14+00:00</created-at> 
  <flag-count type="integer">0</flag-count> 
  <game-id type="integer">6</game-id> 
  <id type="integer">70</id> 
  <ip-address>76.199.6.165</ip-address> 
  <rating type="integer">5</rating> 
  <summary>Citizen Cave</summary> 
  <updated-at type="datetime">2010-09-04T15:38:58+00:00</updated-at> 
  <user-id type="integer">178</user-id> 
  <votes-down type="integer">2</votes-down> 
  <votes-up type="integer">25</votes-up> 
  </review>
- <review>
  <body>Put simply, Dokutsu Monogatari is a work of art. Every element within it - graphics, music, sound, character design, et cetera - is so deliberately well-designed that it's hard to believe this game was created almost entirely by a single person. The most shining element in this game is the gameplay itself. It combines elements of platformer, shooter, and RPG to create a seamless experience. Plus, multiple endings, a few interesting secrets, and gameplay-affecting choices make replay a must. In short, if you don't have this game yet, get it now. There is no reason not to. It will run on almost any machine, it takes up very little hard-drive space, and it costs you absolutely nothing. What are you waiting for?</body> 
  <created-at type="datetime">2008-07-02T12:18:47+00:00</created-at> 
  <flag-count type="integer">0</flag-count> 
  <game-id type="integer">6</game-id> 
  <id type="integer">86</id> 
  <ip-address>138.163.106.71</ip-address> 
  <rating type="integer">5</rating> 
  <summary>One of the Best Games Available</summary> 
  <updated-at type="datetime">2010-10-18T01:14:51+00:00</updated-at> 
  <user-id type="integer">463</user-id> 
  <votes-down type="integer">0</votes-down> 
  <votes-up type="integer">4</votes-up> 
  </review>
- <review>
  <body>Just so you know this review is completely biased. Biased because I love this game so much. The game play is solid. The Story is quite good if a bit silly at times. The characters are very real and I got very attached to some. { If you have ever played a classic metroid game and enjoyed you will most likely enjoy this. If you are playing it though make sure to get the best ending. It adds a lot to the game. I think this is my favorite game, console, P.C., hand held, indie or retail, ever.</body> 
  <created-at type="datetime">2009-06-22T03:36:54+00:00</created-at> 
  <flag-count type="integer">0</flag-count> 
  <game-id type="integer">6</game-id> 
  <id type="integer">459</id> 
  <ip-address>71.17.16.237</ip-address> 
  <rating type="integer">5</rating> 
  <summary /> 
  <updated-at type="datetime">2010-05-20T02:40:26+00:00</updated-at> 
  <user-id type="integer">1166</user-id> 
  <votes-down type="integer">0</votes-down> 
  <votes-up type="integer">2</votes-up> 
  </review>
- <review>
  <body>I feel a strong need to write a review for this game, despite that you've probably heard it all before. This is, without a doubt, one of my favourite Indie freeware games. The game's storyline is massive and superb, as are the amount of characters/enemies in the game. This action/platformer game is famous in the Indie world, and not many people that read this will of not played it. This game litterally has no flaws. Even the download size is extremely small for such a lengthy game. Another notable part of this wonderful game is the music. The music in this game is truly marvellous. I could (and do, for a matter of fact) sit and listen to the music for several hours as a seperate form of entertainment. If you're one of the very few who have not yet played this god-send of a game, I urge you to do so now. You will not be disappointed, so long as you have an ounce of good taste in games. Apart from that, there's hardly anything I can add to this review that you won't already know. If you've already played this and loved it, make sure you also play Daisuke Amaya's (Pixel's) 'Ikachan' game. It's just as magical as Cave Story, which is saying something. ~Toadsanime</body> 
  <created-at type="datetime">2008-07-01T03:40:02+00:00</created-at> 
  <flag-count type="integer">0</flag-count> 
  <game-id type="integer">6</game-id> 
  <id type="integer">13</id> 
  <ip-address>90.218.18.155</ip-address> 
  <rating type="integer">5</rating> 
  <summary>Doukutsu Monogatari: Cave Story</summary> 
  <updated-at type="datetime">2009-05-28T11:13:11+00:00</updated-at> 
  <user-id type="integer">210</user-id> 
  <votes-down type="integer">2</votes-down> 
  <votes-up type="integer">4</votes-up> 
  </review>
- <review>
  <body>Cave story is a must try for anyone interested in seeing what the indie game scene is all about. It's a retro style platformer with level design and advancement like Castlevania: SotN or Super Metroid. You pick up many different and fun weapons throughout your adventure which can all be leveled up through XP you get from killing the large variety of enemies. Artistically this game is a beauty. It's also a pretty long/large game so you won't be done with this too quick. Download it, you won't regret it!</body> 
  <created-at type="datetime">2008-07-01T20:54:41+00:00</created-at> 
  <flag-count type="integer">0</flag-count> 
  <game-id type="integer">6</game-id> 
  <id type="integer">60</id> 
  <ip-address>122.109.82.236</ip-address> 
  <rating type="integer">5</rating> 
  <summary>The pinnacle of indie gaming.</summary> 
  <updated-at type="datetime">2009-05-28T11:14:15+00:00</updated-at> 
  <user-id type="integer">448</user-id> 
  <votes-down type="integer">1</votes-down> 
  <votes-up type="integer">2</votes-up> 
  </review>
- <review>
  <body>This is the first time ever that I felt urged to write a review for a game that I have played, and that is saying something. Everything in Cave Story is made by one person, which makes it absolutely surprising how excellent this game is in every perspective. This is, like everyone has already said, essential to play if you are looking what indie games are exactly, or even if you want to spend time on a good game. So play it.</body> 
  <created-at type="datetime">2008-07-11T08:54:59+00:00</created-at> 
  <flag-count type="integer">0</flag-count> 
  <game-id type="integer">6</game-id> 
  <id type="integer">140</id> 
  <ip-address>85.147.212.30</ip-address> 
  <rating type="integer">5</rating> 
  <summary>This is pure gold</summary> 
  <updated-at type="datetime">2010-05-20T02:41:27+00:00</updated-at> 
  <user-id type="integer">492</user-id> 
  <votes-down type="integer">2</votes-down> 
  <votes-up type="integer">2</votes-up> 
  </review>
- <review>
  <body>This is the first and only game with 'pixel art' where I don't find the art to be forced. Every other game in comparison feels like the pixel art is used as a gimmick where the art and the world never seems to blend together. Simply put, the one and ONLY adventure which flows smoothly from start till the end. Must play, even if you hate pixel art..</body> 
  <created-at type="datetime">2008-07-06T16:35:13+00:00</created-at> 
  <flag-count type="integer">0</flag-count> 
  <game-id type="integer">6</game-id> 
  <id type="integer">120</id> 
  <ip-address>221.134.236.4</ip-address> 
  <rating type="integer">5</rating> 
  <summary>Art</summary> 
  <updated-at type="datetime">2009-05-28T11:13:53+00:00</updated-at> 
  <user-id type="integer">486</user-id> 
  <votes-down type="integer">3</votes-down> 
  <votes-up type="integer">3</votes-up> 
  </review>
- <review>
  <body>It's hard to even write a review for Cave Story without it degenerating into me stamping my foot and shrieking that you stop reading this and go play it NOW! I guess all I have to say is that Cave Story is a breathtaking and flawless work of art. The gameplay is OK too. The story is pretty good. The graphics are poor but cute. But you might as well complain about the cheap canvas of a Picasso. You'll fall in love with the characters, you'll thirst to explore the vibrant and fascinating world, you'll cry and laugh at the right parts, and you'll drop Cave Story references on the internet for years. Cave Story isn't just the best indie game ever made, it's one of the best video games ever made period.</body> 
  <created-at type="datetime">2010-09-12T01:14:23+00:00</created-at> 
  <flag-count type="integer">0</flag-count> 
  <game-id type="integer">6</game-id> 
  <id type="integer">617</id> 
  <ip-address>71.176.160.240</ip-address> 
  <rating type="integer">5</rating> 
  <summary>This is the most flawless game that I have ever played.</summary> 
  <updated-at type="datetime">2010-10-18T01:17:07+00:00</updated-at> 
  <user-id type="integer">3079</user-id> 
  <votes-down type="integer">1</votes-down> 
  <votes-up type="integer">0</votes-up> 
  </review>
- <review>
  <body>This game is great! I registered an account here just so I could rate it and tell people how good it really is. I can't believe a developer hasn't picked this up yet. This game is far better than most commercial games. It at least belongs on the DS or Xbox Live. I can't recommend it enough, more people need to hear about this game.</body>

but it always returns -1 , i used the search function ..but nothing seemed to help with my problem

Edited by RunDLC
Link to comment
Share on other sites

sorry for the double post could not find the edit button for some reason ;)

anyways the only error that shows up is

No DOCTYPE found! Checking XML syntax only.

how would that prevent my code from working? how can i fix it? any reading material on this subject

Edited by RunDLC
Link to comment
Share on other sites

Hey, not sure what your problem is but I found this to work:

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

_XMLFileOpen("http://db.tigsource.com/games/cave-story.xml")

Local $sLvl = _XMLGetValue("/game/average-rating")
_ArrayDisplay($sLvl)

_XMLDomWrapper.au3 is found here: http://www.autoitscript.com/forum/index.php?showtopic=19848

Link to comment
Share on other sites

thanks ;)

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

_XMLFileOpen("http://db.tigsource.com/games/cave-story.xml")
$sLvl = _XMLGetValue("/game/average-rating")
msgbox(0,"",$sLvl[1])

figured it out after that , this is an example

Edited by RunDLC
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...