function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Praetorian65Praetorian65 

Code to create objects from XML

I have a custom object called License. I also have an external asp page that will dynamically generate some XML with most of the data needed to create a new License object (one field I have to work out from the others, but nothing too hard). I need to write some code that can import the data say once a day but I have no idea how to go about doing this. None of the documentation I've read hints at anything like this. I don't know where to start.
JeremyKraybillJeremyKraybill
If you need to do the XML downloading and parsing in Apex, you'll want to use XmlStreamReader - see the documentation in the Apex dev guide. The documentation there is a little thin, but since it's based on the Java version, you can look up all kinds of examples over the web. This thread also points to an example on Google code which shows XmlStreamReader in action.

Honestly I'm not crazy about having a bunch of Apex code doing daily reads and XML decodes -- if I had the ability, I'd be using your external code to construct a SF Web Service API call to do the insert(s) directly. I just find it easier to write a lot of appropriate error handling / retry logic / logging / etc. in an external place.

Hope this helps.

Jeremy Kraybill
Austin, TX


Message Edited by JeremyKraybill on 12-19-2008 07:06 AM