Note that there are some explanatory texts on larger screens.

plurals
  1. POParse XML into object
    text
    copied!<p>Here is the XML:</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;object&gt; &lt;body&gt;tests&lt;/body&gt; &lt;send_results type="null" /&gt; &lt;note_class&gt;none&lt;/note_class&gt; &lt;users type="list" /&gt; &lt;title&gt;test&lt;/title&gt; &lt;time_sent type="null" /&gt; &lt;image type="null" /&gt; &lt;to_customers type="boolean"&gt;False&lt;/to_customers&gt; &lt;time_created&gt;2013-06-26T16:40:50&lt;/time_created&gt; &lt;num_sends type="integer"&gt;0&lt;/num_sends&gt; &lt;time_scheduled type="null" /&gt; &lt;dealership&gt;/api/v1/dealerships/10/&lt;/dealership&gt; &lt;id type="integer"&gt;22&lt;/id&gt; &lt;send_rate&gt;none&lt;/send_rate&gt; &lt;send_method&gt;email&lt;/send_method&gt; &lt;reply_to_email&gt;do_not_reply@williamson-cadillac.com&lt;/reply_to_email&gt; &lt;response_link type="null" /&gt; &lt;to_users type="boolean"&gt;True&lt;/to_users&gt; &lt;resource_uri&gt;/api/v1/notifications/22/&lt;/resource_uri&gt; &lt;/object&gt; </code></pre> <p>I'm trying to parse the Xml into an object...</p> <pre><code> var query = from m in parsedXml.Decendants("object") select new Notifications { Body = (string)m.Element("body"), SendResults = (string)m.Element("send_results"), NoteClass = (string)m.Element("note_class"), Users = m.Element("users").Elements().Select(e =&gt; (string)e.Element("value")).ToList(), Title = (string)m.Element("title"), TimeSent = (string)m.Element("time_sent"), Image = (string)m.Element("image"), ToCustomers = (string)m.Element("to_customers"), TimeCreated = (string)m.Element("time_created"), NumSends = (string)m.Element("num_sends"), TimeScheduled = (string)m.Element("time_scheduled"), Dealership = (string)m.Element("dealership"), Id = (string)m.Element("id"), SendRate = (string)m.Element("send_rate"), SendMethod = (string)m.Element("send_method"), ReplyToEmail = (string)m.Element("reply_to_email"), ResponseLink = (string)m.Element("response_link"), ToUsers = (string)m.Element("to_users"), ResourceUri = (string)m.Element("resource_uri"), }; </code></pre> <p>and I keep on getting "nothing" or "null" in the variable "query".</p> <p>I can't figure this out - I've tried many different things. Thanks for you help in these matters.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload