Re: XML to AppleScript Record
Re: XML to AppleScript Record
- Subject: Re: XML to AppleScript Record
- From: Skeeve <email@hidden>
- Date: Wed, 05 Mar 2008 11:41:42 +0100
Stockly, Ed wrote:
<root>
<xmlDataFormat Version="1.1">
<dataTagFoo>
<dataTagBar>
"Data"
</dataTagBar>
<dataTagMore>
"More Data Data"
</dataTagMore>
</dataTagFoo>
</root>
That's not XML. At least not well-formed.
So let's try this one instead:
<root>
<xmlDataFormat Version="1.1"/>
<dataTagFoo>
<dataTagBar>
"Data"
</dataTagBar>
<dataTagMore>
"More Data Data"
</dataTagMore>
</dataTagFoo>
</root>
Should translate as:
{root:{{xmlDataFormat:{version:"1.1:"}}, {dataTagFoo:{dataTagBar:"Data"}},
{dataTagMore:"More Data Data"}}}
No. It shouldn't! You're mixing attributes and content.
If you need both, attributes and content you'd better go with this:
{root:{
attributes:{},
contents:{
xmlDataFormat:{
attributes:{
version:"1.1:"
},
contents:{}
}
dataTagFoo:{
attributes:{},
contents:{
dataTagBar:{
attributes:{},
contents:"\n \"Data\"\n "
},
dataTagMore:{
attributes:{},
contents:"\n \"More Data Data\"\n "
}
}
}
}
}}
Of course this format doesn't support mixed content. Each Ellement can
only have either text content or child elements.
If you want to install some Perl Modules, you could achieve this with
XML::Twig, converting the XML to AppleScript source code.
Or you create an XSLT that does the same and include (e.g.) saxon into
your AppleScript application.
Of course all the other objections you already read here are still valid.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden