I'm trying to create an XML file to conform to Indeed.com's Job Listing XML.
It looks like:
<?xml version="1.0" encoding="utf-8"?>
<source>
<publisher>Super X Job Site</publisher>
<publisherurl>http://www.superxjobsite.com</publisherurl>
<job>
<title><![CDATA[Sales Executive]]></title>
<date><![CDATA[Fri, 10 Dec 2005 22:49:39 GMT]]></date>
<referencenumber><![CDATA[unique123131]]></referencenumber>
<url><![CDATA[http://www.superxjobsite.com/job/123]]></url>
<company><![CDATA[Big ABC Corporation]]></company>
<city><![CDATA[Phoenix]]></city> <state><![CDATA[AZ]]></state>
<country><![CDATA[US]]></country> <postalcode><![CDATA[85003]]></postalcode>
<description><![CDATA[Some really long job description goes here.]]></description>
</job>
[ more jobs ...]
Now, right now I have a IEnumberable of "Jobs", which has properties which match each one of the XML elements above.
What is the best way to generate this XML document and return it as an ActionResult in ASP.NET MVC?
One way, is I could construct the XML string manually like:
String xmlDoc = "<?xml version="1.0" encoding="utf-8"?>";
xmlDoc += "<source>";
xmlDoc += "<publisher>Super X Job Site</publisher>";
xmlDoc += "<publisherurl>http://www.superxjobsite.com</publisherurl>";
foreach(Job job in Jobs)
{
xmlDoc += "<job>";
xmlDoc += "<description>" + job.Description + "</description>";
...
}
While I know this method would work, is there a better way I should be doing this so I can generate this XML?