You need to sign in to do that
Don't have an account?
Getting and opening an XML file in apex code
Hi,
I need to develop a class where I read in an XML file, then parse through the data, etc. This file will not be chosen manually by a user, rather I have the URL where the file is located and I need to get it from that location and open it in the code.
My question is, how do I get this file from the specified URL location and open it so that I can parse it in my code? I have seen many examples where the file is selected manually using apex:inputfile in the Visualforce page, but I have not been able to find anything yet where I can simply specify the location of a file and then call a method to read its contents.
Thanks in advance!
Link -> http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_xml_XmlStream_reader.htm
Thanks, this will help when I need to parse the XML. However my question wasn't so much on how to parse the XML, as it was about how to GET the file given a specific URL without a Visualforce page.
Thanks!
Check this out:
It's taken from the HttpResponse Class Section in the Apex Doc
I think this might help you with your question. When you need to GET the file from a external resource that will be perfect, I guess. On the other hand, I don't know if there might be a easiert way to read Static Resources from the platform!
Cheers!