Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: XML file problem



Everybody, thanks for your help. I've finally managed to get some data out of my XML file.

I only don't see how to get all the children's data (data1, data2 and data3) seperately in an array.

Now I just use:

set theChild to XMLChild theRoot index 1
set data1 to XMLGetText (XMLXPath theChild with "data1")
set data2 to XMLGetText (XMLXPath theChild with "data2")
set data3 to XMLGetText (XMLXPath theChild with "data3")

... which does the same thing, only in 3 variables, but what if I don't exactly know how many children there are and I want to assemble all their values in one array?
Never mind, I don't have to do this myself, but maybe it's a useful question for the rest of the list...

Thanks again,
Jasper.

On 17 Feb 2007, at 05:29PM, Andreas Kiel wrote:

Have a look at the Satimage XMLlib osax, this works flawless even with huge XMLs - at least for me.
data1 seems to be a comment and is not closed, anyway

so data values (using XMLlib osax) will be
"<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>
<myxml>
<child>
<data1><![CDATA[xxxx]]></data1>
<data2>yyyy</data2>
<data3>zzzz</data3>
</child>
</myxml>
"

set myXML to XMLOpen the result
set theRoot to XMLRoot myXML
set childData to XMLGetText (XMLXPath theRoot with "child")
XMLClose myXML

--> xxxxyyyyzzzz


Regards
Andreas

On 17.02.2007, at 18:10, Jasper Van Proeyen wrote:

Hi list,

I have an XML file with the following structure:

<?xml version="1.0" encoding="iso-8859-1" ?>
<myxml>
<child>
<data1><![CDATA[xxxx]]</data1>
<data2>yyyy</data2>
<data3>zzzz</data3>
</child>
</myxml>

Given that the XML file is generated online: can I just use the following line to store the complete contents of the XML file in a variable and somehow still access the "xxxx", "yyyy" and "zzzz" strings?
set theXML to do shell script "curl --silent 'http://myserver.com/generatexml.php" (output of the URL is an XML file)

If so, how can I store the 3 string values into an array (or 3 seperate values - it doesn't matter actually)?
If not, what's the best way to access these strings then?

I've tried via "System Events", but that didn't work:
set valueY to value of XML element "data2" of XML elements of XML element "child" of XML element "myxml" of XML element 1 of contents of theXML (gives a very strange "Can't make \"myxml\" into type integer" error)

Any help would be appreciated.

Regards,
Jasper.

––––––––


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-studio mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-studio mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-studio/email@hidden

This email sent to email@hidden

References: 
 >XML file problem (From: Jasper Van Proeyen <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.