Results 1 to 9 of 9

Thread: Parsing this XML

  1. #1
    Join Date
    Jul 2008
    Posts
    136
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Parsing this XML

    how can i parse this XML

    http://pastebin.com/raw.php?i=cQh47fBJ


    so that each loop i do i can fill these variables
    e.g.
    for first loop

    colour = 2565928
    x = 976
    y = 228


    loop 2

    colour = 2763307
    x = 970
    y = 208


    and so on ..

    i started on it using GetPage but im having problem going down line .=/

    Simba Code:
    Remote := GetPage('http://pastebin.com/raw.php?i=cQh47fBJ');
      writeln('hi');
      for I := 0 to 31 do
      begin
      RemoteVersion := StrToInt(Between('</Item', '>', Remote));
       writeln(RemoteVersion);
       end;
      Colour := StrToInt(Between('<Colour>', '</Colour>', Remote));
      CoordX := StrToInt(Between('<CoordX>', '</CoordX>', Remote));
      CoordX := StrToInt(Between('<CoordY>', '</CoordY>', Remote));

  2. #2
    Join Date
    Oct 2008
    Location
    C:\Simba\Includes\
    Posts
    7,566
    Mentioned
    19 Post(s)
    Quoted
    180 Post(s)

    Default

    Why use XML? Why not just build an array of the values in your script? Or better yet, a object model.
    Away for awhile, life is keeping me busy. | Want to get my attention in a thread? @Kyle Undefined; me.
    { MSI Phoenix || SRL Stats Sigs || Paste || Scripts || Quotes || Graphics }

    When posting a bug, please post debug! Help us, help you!

    I would love to change the world, but they won't give me the source code. || To be the best, you've got to beat the rest. || Logic never changes, just the syntax.
    If you PM me with a stupid question or one listed in FAQ, or about a script that is not mine, I will NOT respond.


    SRL is a Library of routines made by the SRL community written for the Program Simba. We produce Scripts for the game Runescape.


  3. #3
    Join Date
    Feb 2006
    Posts
    3,044
    Mentioned
    4 Post(s)
    Quoted
    21 Post(s)

    Default

    Hello, there you go


    Simba Code:
    Program Get_Info;


    var
      Name, Colour, CoordX, CoordY, Part, Source :String;
      I :Integer;


    begin
      Source := GetPage('http://pastebin.com/raw.php?i=cQh47fBJ');
      for I := 0 to 31 do
      begin
        Part := Between('<Item' + IntToStr(I) + '>', '</Data>', Source);
        Name := Between('<Name>', '</Name>', Part);
        Colour := Between('<Colour>', '</Colour>', Part);
        CoordX := Between('<CoordX>', '</CoordX>', Part);
        CoordY := Between('<CoordY>', '</CoordY>', Part);

        WriteLn('Information For Current Data(' + IntToStr(I) + ')');
        WriteLn(Name);
        WriteLn(Colour);
        WriteLn(CoordX);
        WriteLn(CoordY);
      end;
    end.


    ~Home

  4. #4
    Join Date
    Jul 2008
    Posts
    136
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    wow thanks man , but i was jsut wondering how u managedd to scan each line
    Part := Between('<Item' + IntToStr(I) + '>', '</Data>', Source);
    Name := Between('<Name>', '</Name>', Part);


    why use source and part ?

  5. #5
    Join Date
    Feb 2006
    Posts
    3,044
    Mentioned
    4 Post(s)
    Quoted
    21 Post(s)

    Default

    First I will get whole source of that page.

    Then I will get Correct part of source. Using variable (I).

    It's just simple playing around with Between


    ~Home

  6. #6
    Join Date
    Oct 2008
    Location
    C:\Simba\Includes\
    Posts
    7,566
    Mentioned
    19 Post(s)
    Quoted
    180 Post(s)

    Default

    Source is the data that is returned from the GetData();

    Part is getting the correct section of code. "<Item + IntToStr(I)" will walk down the nodes.

    'd
    Away for awhile, life is keeping me busy. | Want to get my attention in a thread? @Kyle Undefined; me.
    { MSI Phoenix || SRL Stats Sigs || Paste || Scripts || Quotes || Graphics }

    When posting a bug, please post debug! Help us, help you!

    I would love to change the world, but they won't give me the source code. || To be the best, you've got to beat the rest. || Logic never changes, just the syntax.
    If you PM me with a stupid question or one listed in FAQ, or about a script that is not mine, I will NOT respond.


    SRL is a Library of routines made by the SRL community written for the Program Simba. We produce Scripts for the game Runescape.


  7. #7
    Join Date
    Jul 2008
    Posts
    136
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    oh i see , hmm i learnt parsing on C was comparing string by reading it line by line, is tht method possible?

  8. #8
    Join Date
    Oct 2009
    Location
    Stockton, CA
    Posts
    2,040
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    If you really want to just explode it.
    Simba Code:
    str := GetPage("page");
    lines (TStringArray) := explode(chr(10), str);

    Edit: Also, be sure to know if your file uses line feed, carriage return, or both for line breaks.
    Last edited by Sex; 12-15-2011 at 12:27 AM.
    Join the IRC! irc.rizon.net:6667/srl | SQLite (0.99rc3+) | SRL Doc | Simba Doc | Extra Simba Libraries (openSSL & sqlite3)
    Quote Originally Posted by #srl
    10:45 < Toter> daphil when can get sex anyday I want
    10:45 < Toter> he is always on #SRL
    "A programmer is just a tool which converts caffeine into code"

  9. #9
    Join Date
    Jul 2008
    Posts
    136
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    wat is explode ?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •