Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You'll only get the <em>first</em> element that way, because that's what the <a href="http://msdn.microsoft.com/en-us/library/system.xml.linq.xcontainer.element.aspx" rel="nofollow"><code>Element</code></a> method gives you: the first child element with the given name.</p> <p>If you want multiple elements you can just use <a href="http://msdn.microsoft.com/en-us/library/system.xml.linq.xcontainer.elements.aspx" rel="nofollow"><code>Elements</code></a> instead:</p> <pre><code>// Note: the query expression here is pointless. var results = from c in rootElement.Descendants("InputPath") select c; foreach (XElement _path in results) { string value = _path.Elements("path").Value; // Use value here... } </code></pre> <p>Alternatively, use the <a href="http://msdn.microsoft.com/en-us/library/bb351784.aspx" rel="nofollow"><code>Elements</code></a> extension method and do it all in one go:</p> <pre><code>foreach (var path in rootElement.Descendants("InputPath").Elements("path")) { string value = path.Value; // Use value here } </code></pre> <p>If that doesn't help, please give more information about what you're trying to do and what the problem is.</p> <p>If by "last" you mean "the element contents" that's because you're using the <code>Value</code> property. If you want the <em>attributes</em> within the path element, you need the <a href="http://msdn.microsoft.com/en-us/library/system.xml.linq.xelement.attribute.aspx" rel="nofollow"><code>Attribute</code></a> method, as shown by IamStalker, although personally I'd usually cast the <code>XAttribute</code> to string (or whatever) rather than using the <code>Value</code> property, in case the attribute is missing. (It depends on what you want the behaviour to be in that case.)</p>
    singulars
    1. This table or related slice is empty.
    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