Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 15 of 26
  1. #1
    Join Date
    May 2007
    Posts
    52

    Getting specific information from XML

    Hi, I have many XML files that have the next format:

    <songs>
    <song path="LINK.MP3" bild="img/s.jpg" artist="NAME OF THE ARTIST" title="SONG TITLE"/>
    </songs>

    The problem is that I don't know how to "extratc" that information to use it into my project.

    I need to get them all (but the most important is the "song path".

    PD: This will be easier is the structure of the XML was something like:
    <song>
    <path>LINK.MP3</path>
    <artist>ARTIST</artist>
    <title>TITLE</title>
    </song>


    Bye and thanks

  2. #2
    Join Date
    Jan 2001
    Location
    Anderson Island, WA, USA
    Posts
    2,863
    I didn't try anything; but I don't think the built in XML object will hanlde self-ending objects nicely

    <start something=something/>

    are the xml files "individual" (ie one xml file has one path?)


    (Click here to contact me)
    Providing Independent Professional Consulting Services for
    IndigoRose products, World Wide.
    Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)

  3. #3
    Join Date
    Apr 2004
    Location
    Vancouver, Canada
    Posts
    1,790
    You will need to use the GetAttribute action. Look at the help topic for XML. GetAttribute in the help file for an example.

    So in your case, to get the title of the second song you would use.

    title = XML.GetAttribute("songs/song:2", "title");
    Last edited by Dermot; 10-23-2008 at 05:33 PM.
    Dermot

    I am so out of here

  4. #4
    Join Date
    May 2007
    Posts
    52
    Well Dermot, thank you.

    Im gonna try with the GetAtribute action

    Thanks again !

  5. #5
    Join Date
    May 2007
    Posts
    52
    Hi, Im here again.

    Im doing some test before start building the app.

    Ive created a new project and then Ive added an Input, a button and a label.

    In the input I will put the URL of the XML file.

    The button will collect that URL (onClick) and will put one atribute of that XML on the label.

    When I execute the app, the label gets white (without content).

    Ive used this code for the onClick event on the button:

    urlXML = Input.GetText("Input1"); // gets the URL of the XML
    XML.Load("urlXML"); // loads the XML file
    getURL = XML.GetAttribute("songs/song:2", "path"); // get the atribute
    Label.SetText("Label1", getURL); // Writes the info on the label

    There ir something wrong or Ive missed something?

    Bye and thanks

  6. #6
    Join Date
    Apr 2004
    Location
    Vancouver, Canada
    Posts
    1,790
    Are you trying to open an xml file located on the web? If so then that's your problem. You will need to download the file and save to your local drive, then load it.
    Dermot

    I am so out of here

  7. #7
    Join Date
    May 2007
    Posts
    52
    Oh, its okay.

    Whats the better way to do that?

    Will be great, if is possible to download it to a temporary folder and delete it when u close the app or when Windows is turned off.

  8. #8
    Join Date
    Jan 2001
    Location
    Anderson Island, WA, USA
    Posts
    2,863
    Quote Originally Posted by nicoh View Post
    Oh, its okay.

    Whats the better way to do that?

    Will be great, if is possible to download it to a temporary folder and delete it when u close the app or when Windows is turned off.
    Have a look at HTTP.Download(), from there you can download a file to the _TempFolder


    so something like
    Code:
    HTTP.Download( cXMLURL, _TempFolder.."\\Temp.xml");
    from there you can use the XML object & then use File.Delete() to remove the xml temp file...


    (Click here to contact me)
    Providing Independent Professional Consulting Services for
    IndigoRose products, World Wide.
    Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)

  9. #9
    Join Date
    May 2007
    Posts
    52
    Hey jassing, thanks for helping me.

    With the tip that you gave me, Ive done this:

    obtURL = Input.GetText("urlInput"); // gets the xml url from an input
    HTTP.Download("obtURL", _TempFolder.."\\mp3.xml"); // downloads it to the hd
    obtMP3 = XML.Load(_TempFolder.."\\mp3.xml"); // loads it
    urlMP3= XML.GetAttribute(_TempFolder.."\\mp3.xml", "songs/song:2", "path"); // gets the attribute
    Label.SetText("Label1", urlMP3); // writes the attrib. in a label object.

    I still having the same problem (nothing is shown in the label).

    I think that Im making a mistake when Im obtaining / loading the URL:
    obtMP3 = XML.Load(_TempFolder.."\\mp3.xml");
    urlMP3= XML.GetAttribute(_TempFolder.."\\mp3.xml", "songs/song:2", "path");

    Is this right?

    Thanks again

  10. #10
    Join Date
    Apr 2004
    Location
    Vancouver, Canada
    Posts
    1,790
    I guess you didn't look at my previous example or the help file.

    urlMP3= XML.GetAttribute("songs/song:2", "path");
    Dermot

    I am so out of here

  11. #11
    Join Date
    May 2007
    Posts
    52
    Quote Originally Posted by Dermot View Post
    I guess you didn't look at my previous example or the help file.

    urlMP3= XML.GetAttribute("songs/song:2", "path");
    Of course I did, but Ive got the same error so Ive tried loading the action directly from the AMS Wizard.

  12. #12
    Join Date
    Apr 2004
    Location
    Vancouver, Canada
    Posts
    1,790
    You have this.

    urlMP3= XML.GetAttribute(_TempFolder.."\\mp3.xml", "songs/song:2", "path");

    When you should have this.

    urlMP3= XML.GetAttribute("songs/song:2", "path");
    Dermot

    I am so out of here

  13. #13
    Join Date
    May 2007
    Posts
    52
    Quote Originally Posted by Dermot View Post
    You have this.

    urlMP3= XML.GetAttribute(_TempFolder.."\\mp3.xml", "songs/song:2", "path");

    When you should have this.

    urlMP3= XML.GetAttribute("songs/song:2", "path");
    Yes, Ive tried with both and I still having the same error :S

  14. #14
    Join Date
    Jun 2007
    Location
    Delphi II
    Posts
    1,534
    Often, errors in XML parsing occur because of a syntax error in the XML file itself.

    For instance, if you are missing a close tag, none of the XML call functions will work properly. Also, if you don't have quotes around an attribute, you will get errors.

    My recommendation is to make an XML file with as little information as possible in order to test your program.

    for example:

    Code:
    <songs>
         <song title="My Song" extension=".mp3">
         </song>
    </songs>
    Start with something simple like that, and errors will be easier to find.

    I have a program that generates thousands of lines of code for one XML file (galaxy generator, including start systems and planets) and then can read lines back when listing statistics. I had errors like yours when I started and used the above-mentioned method to find them. Start simple, then build you process.

    Keep Dermot's quote in mind when building any complex system.
    Last edited by Centauri Soldier; 10-24-2008 at 02:10 PM.

  15. #15
    Join Date
    Jan 2001
    Location
    Anderson Island, WA, USA
    Posts
    2,863
    What is the error your are getting?
    Do you have control over the xml format?
    does one xml file have more than one mp3 information?


    (Click here to contact me)
    Providing Independent Professional Consulting Services for
    IndigoRose products, World Wide.
    Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)

Similar Threads

  1. How to pick the right information from XML?
    By Friethoe in forum AutoPlay Media Studio 6.0
    Replies: 4
    Last Post: 03-22-2006, 04:50 PM
  2. Spotlight: XML Actions Plugin
    By Desmond in forum AutoPlay Media Studio 5.0
    Replies: 1
    Last Post: 03-15-2004, 03:56 PM
  3. INFO: Changing the Resource Information for a Setup.exe
    By Support in forum Setup Factory 5.0
    Replies: 0
    Last Post: 10-15-2002, 02:09 PM
  4. INFO: Changing the Resource Information for a Setup.exe
    By Support in forum Setup Factory 6.0 Knowledge Base
    Replies: 0
    Last Post: 10-15-2002, 02:09 PM
  5. HOWTO: Open an HTML Help File to a Specific Topic
    By Support in forum AutoPlay Media Studio 4.0 Examples
    Replies: 0
    Last Post: 10-01-2002, 02:24 PM

Posting Permissions

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