Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As Adam precises in the comment, XName are convertible to a string, but that string requires the namespace when there is one. That's why the comparison of .Name to a string fails, or why you can't pass "Person" as a parameter to the XLinq Method to filter on their name.<br> XName consists of a prefix (the Namespace) and a LocalName. The local name is what you want to query on if you are ignoring namespaces.<br> Thank you Adam :)</p> <p>You can't put the Name of the node as a parameter of the .Descendants() method, but you can query that way : </p> <pre><code>var doc= XElement.Parse( @"&lt;s:Envelope xmlns:s=""http://schemas.xmlsoap.org/soap/envelope/""&gt; &lt;s:Body xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema""&gt; &lt;Request xmlns=""http://CompanyName.AppName.Service.ContractA""&gt; &lt;Person&gt; &lt;CreditCardNumber&gt;83838&lt;/CreditCardNumber&gt; &lt;FirstName&gt;Tom&lt;/FirstName&gt; &lt;LastName&gt;Jackson&lt;/LastName&gt; &lt;/Person&gt; &lt;Person&gt; &lt;CreditCardNumber&gt;789875&lt;/CreditCardNumber&gt; &lt;FirstName&gt;Chris&lt;/FirstName&gt; &lt;LastName&gt;Smith&lt;/LastName&gt; &lt;/Person&gt; &lt;/Request&gt; &lt;/s:Body&gt; &lt;/s:Envelope&gt;"); </code></pre> <p><strong>EDIT :</strong> <em>bad copy/past from my test :)</em></p> <pre><code>var persons = from p in doc.Descendants() where p.Name.LocalName == "Person" select p; foreach (var p in persons) { Console.WriteLine(p); } </code></pre> <p>That works for me...</p>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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