Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><a href="http://msdn.microsoft.com/en-us/library/system.xml.linq.xdocument.aspx" rel="nofollow">XDocument</a> will work for this case since you're not using the entire XML structure.</p> <p>Assuming your XML is valid such as:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;result is_array="true"&gt; &lt;item&gt; &lt;candidate_offer_id&gt;175&lt;/candidate_offer_id&gt; &lt;contact_person&gt;Ranjeet Singh&lt;/contact_person&gt; &lt;offer_status&gt;8&lt;/offer_status&gt; &lt;/item&gt; &lt;item&gt; &lt;candidate_offer_id&gt;176&lt;/candidate_offer_id&gt; &lt;contact_person&gt;Ranjeet Singh&lt;/contact_person&gt; &lt;offer_status&gt;8&lt;/offer_status&gt; &lt;/item&gt; &lt;/result&gt; </code></pre> <p>DTO:</p> <pre><code>public class CandidateOffer { public int CandidateOfferId { get; set; } public string ContactPerson { get; set; } public int OfferStatus { get; set; } } </code></pre> <p>Parser:</p> <pre><code>public CandidateOffer ParseCandidateOffer(XElement element) { int candidateOfferId; if(!int.TryParse(element.Element("candidate_offer_id").Value, out candidateOfferId)) { candidateOfferId = 0; } var contactPerson = element.Element("contact_person").Value; int offerStatus; if(!int.TryParse(element.Element("offer_status").Value, out offerStatus)) { offerStatus = 0; } return new CandidateOffer { CandidateOfferId = candidateOfferId, ContactPerson = contactPerson, OfferStatus = offerStatus }; } </code></pre> <p>Usage:</p> <pre><code>var xDocument = XDocument.Parse(xmlString); var candidateOffers = xDocument.XPathSelectElements("//item") .Select(ParseCandidateOffer); foreach(var candidateOffer in candidateOffers) { Console.WriteLine(candidateOffer.CandidateOfferId); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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