• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Lists to XML ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Lists to XML ?


  • Subject: Re: Lists to XML ?
  • From: Steve Mills <email@hidden>
  • Date: Fri, 24 Mar 2017 21:20:00 +0000 (GMT)

On Mar 24, 2017, at 10:37 AM, Jean-Christophe Helary <email@hidden> wrote:

Also, I can't find a way to create the <?xml...> and <!doctype ...> lines at the top of the document, which I guess is related to the previous point...

Here's the code out of one of my Objective-C projects that sets up that part of the xml document:

xmlDoc.characterEncoding = @"UTF-8";

xmlDoc.version = @"1.0";

xmlDoc.standalone = NO;


 
# creation of the <header> element and of it's many attributes
set tmxHeader to current application's NSXMLNode's elementWithName:"header"
set headerCreationTool to (current application's NSXMLNode's attributeWithName:"creationtool" stringValue:"xls2tmx")
set headerCreationToolVersion to (current application's NSXMLNode's attributeWithName:"creationtoolversion" stringValue:"0.1")
set headerSrcLang to (current application's NSXMLNode's attributeWithName:"srclang" stringValue:myTMsrclang)
set headerAdminLang to (current application's NSXMLNode's attributeWithName:"adminlang" stringValue:"en")
set headerDatatype to (current application's NSXMLNode's attributeWithName:"datatype" stringValue:"unknown")
set headerOtmf to (current application's NSXMLNode's attributeWithName:"o-tmf" stringValue:"Microsoft Excel")
set headerSegtype to (current application's NSXMLNode's attributeWithName:"segtype" stringValue:"paragraph")
set headerCreationDate to (current application's NSXMLNode's attributeWithName:"creationdate" stringValue:myDateString)
(tmxHeader's addAttribute:headerCreationTool)
(tmxHeader's addAttribute:headerCreationToolVersion)
(tmxHeader's addAttribute:headerSrcLang)
(tmxHeader's addAttribute:headerAdminLang)
(tmxHeader's addAttribute:headerDatatype)
(tmxHeader's addAttribute:headerOtmf)
(tmxHeader's addAttribute:headerSegtype)
(tmxHeader's addAttribute:headerCreationDate)
 
This sure would be cleaner if you used setAttributesAsDictionary:.
 
(tmxBody's addChild:TUElement)
(tmxRoot's addChild:tmxHeader)
(tmxRoot's addChild:tmxBody)

Are you sure all of these are being added to the correct parent?
 
return tmxRoot's XMLString() as text

And if you want the <?xml...> junk, shouldn't you be getting the NSXMLDocument's text instead of the root object's?

Sent from iCloud's ridiculous UI, so, sorry about the formatting

 _______________________________________________
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

  • Follow-Ups:
    • Re: Lists to XML ?
      • From: Jean-Christophe Helary <email@hidden>
    • Re: Lists to XML ?
      • From: Jean-Christophe Helary <email@hidden>
References: 
 >Re: Lists to XML ? (From: Jean-Christophe Helary <email@hidden>)

  • Prev by Date: Detect when an app is crashed
  • Next by Date: Safari Moving Focus to the URL List in Bookmarks and History Windows after a Search
  • Previous by thread: Re: Lists to XML ?
  • Next by thread: Re: Lists to XML ?
  • Index(es):
    • Date
    • Thread