[SOLVED] How I can get value from XML

Get help using Construct 2

Post » Thu Mar 02, 2017 11:50 am

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!
Last edited by radbrothers on Thu Mar 02, 2017 3:44 pm, edited 1 time in total.
B
12
S
3
Posts: 114
Reputation: 1,432

Post » Thu Mar 02, 2017 12:04 pm

radbrothers wrote: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:

Code: Select all
<?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>
If your vision so exceeds your ability, then look to something closer.
Moderator
B
134
S
30
G
84
Posts: 5,374
Reputation: 58,430

Post » Thu Mar 02, 2017 12:37 pm

@zenox98

Thank you for answer! But is there any way for this case?
B
12
S
3
Posts: 114
Reputation: 1,432

Post » Thu Mar 02, 2017 1:39 pm

[plugin] JSON

Code: Select all
{
"1": 100,
"2": 200,
"3": "http://1",
"4": "http://2"
}


this is JSON format ,not XML
Image
B
65
S
23
G
7
Posts: 1,501
Reputation: 10,888

Post » Thu Mar 02, 2017 2:17 pm

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.
B
12
S
3
Posts: 114
Reputation: 1,432

Post » Thu Mar 02, 2017 3:06 pm

Image

Code: Select all
{
"1": 100,
"2": 200,
"3": "http://1",
"4": "http://2"
}

JSON.Value(0,1)=100
JSON.Value(0,2)=200
JSON.Value(0,3)=http://1
.......
Image
B
65
S
23
G
7
Posts: 1,501
Reputation: 10,888

Post » Thu Mar 02, 2017 3:43 pm

Ok, I understood, thank you @korbaach for help!
B
12
S
3
Posts: 114
Reputation: 1,432


Return to How do I....?

Who is online

Users browsing this forum: rengo, Yahoo [Bot] and 31 guests