Parse XML into SP columns

Apr 11, 2011 at 8:51 PM

I have a client who, when a Adobe form is completed, has the option to email the output as either XML or PDF.  He is currently emailing the PDF to a library, but this has two distinct disadvantages - the files are large, and no real metadata is gathered.

We would instead like to email the xml to a library, and then use JavaScript and SPServices to parse out the data into list columns.  Fortunately the tags are simple and non-reocurring within a single document, so the parsing and using SPServices to populate the items is fairly simple.

I am stuck at the beginning - how can I use SPServices to open up the xml for parsing?

Also, if there is a slicker way to parse the xml other than .split (I am a newbie of sorts - or at least un-schooled) I am open to suggestions!

I live by simple example - lets assume the xml is sample.xml, it is ID one in a library called Output with columns Field1, Field2, Field3 (that correspond to the tags in the xml).  Any examples?



Apr 12, 2011 at 3:30 AM
Edited Apr 12, 2011 at 12:12 PM


I don't think that this is a very good use for SPServices. I think an event handler on the list to process the inbound emails is what you need to make this work. There wouldn't be any way to trigger a script-based solution, as these scripts run client side, not on the server.


Apr 12, 2011 at 12:06 PM

Yep - I agree.  Unfortunately, my organization does not allow client IT support groups to use SPD or any other tools, so I am limited to CEWPs and the like.  I can put in a request for the corporate group to develop a solution, but it is an arduous task at best.

In the past, I have placed code on the default view of the list/library that uses a CAMLQuery that identified any rows that need updating, then run the updates and refreshes the page.  If the CAMLQuery returns 0 rows, it stops the processing.  Not elegant, and certainly can tax the end user if the page has not been hit in awhile, but the best I can do for now.

If you have any suggestions for things that I as a site owner can do, please let me know!  I always appreciate your assistance and insight!


Apr 12, 2011 at 12:17 PM


I understand your situation because it's actually far more common than it should be. IT departments often are what get in the way of developing solutions that the business needs. Not really supposed to be the point, is it?

I do worry about the approach that you outline, though it ought to work most of the time.

jQuery actually parses XML quite well. You can look into SPServices itself (or just the documentation) to see examples of XML parsing,, as that is what is returned from the SharePoint Web Services.

Someone actually was doing almost exactly what you want to do a little while back and we emailed or discussed it somehow. I can't seem to find it!


Apr 12, 2011 at 12:53 PM

Yep - I searched the discussions, but did not stumble across anything.  I will do some googling of jQuery XML parsing.  I saw this example where the xml was a variable, but kept getting empty alerts ( I call jquery 1.4.2 earlier)

var xml = "<music><album>Beethoven</album></music>"; 
var result = $(xml).find("album").text(); 


Thanks - Bill


Apr 12, 2011 at 1:09 PM

I would say that a large number of the discussion threads here probably include some XML parsing. Here's an example from today:

Your example above isn't really valid, as you're trying to parse a string which simply has XML-like values in it.