[SOLVED] How I can get value from XML

0 favourites
  • 7 posts
  • Hi all!

    For example i have this XML:

    {

    "1": 100,

    "2": 200,

    "3": "http://1",

    "4": "http://2" ,

    }

    How i can get "100", "200", "http://1" and "http://2" from XML?

    I read manuals and tutorials but i can't do it with this.

    Thank you!

  • Hi all!

    For example i have this XML:

    {

    "1": 100,

    "2": 200,

    "3": "http://1",

    "4": "http://2" ,

    }

    How i can get "100", "200", "http://1" and "http://2" from XML?

    I read manuals and tutorials but i can't do it with this.

    Thank you!

    As the manual states the xml must be valid xpath xml, which the sample

    you have posted obviously isn't.

    Typical example of valid XML would be:

    <?xml version="1.0" encoding="utf-8" ?>
    <Catalog>
            <Album artist="The Last Shadow Puppets" title="The Age Of The Understatement">
                    <Track rating="4" length="P3M7S">The Age Of The Understatement</Track>
                    <Track rating="3" length="P2M18S">Standing Next To Me</Track>
                    <Track rating="5" length="P2M26S">Calm Like You</Track>
                    <Track rating="3" length="P3M38S">Separate and Ever Deadly</Track>
                    <Track rating="2" length="P2M37S">The Chamber</Track>
                    <Track rating="3" length="P2M44S">Only The Truth</Track>
            </Album>
            <Album artist="Kings Of Leon" title="Because Of The Times">
                    <Track rating="4" length="P7M10S">Knocked Up</Track>
                    <Track rating="2" length="P2M57S">Charmer</Track>
                    <Track rating="3" length="P3M21S">On Call</Track>
                    <Track rating="4" length="P3M09S">McFearless</Track>
                    <Track rating="1" length="P3M59S">Black Thumbnail</Track>
            </Album>
    </Catalog>[/code:gwc970x1]
  • zenox98

    Thank you for answer! But is there any way for this case?

  • [plugin] JSON

    {
    "1": 100,
    "2": 200,
    "3": "http://1",
    "4": "http://2" 
    }
    [/code:endtvw6d]
    
    [i]this is JSON format ,not XML[/i]
  • Hi korbaach

    Yes you are right, it is JSON who initially comes as a response from a web service. I tried to get this values through AJAX object and load in XML.

    Thanks for the link to JSON plugin, but I don't know how use it with AJAX.Last Data. I will be grateful for any help with this.

  • {
    "1": 100,
    "2": 200,
    "3": "http://1",
    "4": "http://2" 
    }[/code:21xw0iil]
    [i]JSON.Value(0,1)=100
    JSON.Value(0,2)=200
    JSON.Value(0,3)=http://1
    .......[/i]
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Ok, I understood, thank you korbaach for help!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)