c# - Querying Linq to xml with an incomplete value -


i have question querying linq.

for example have xml :

<output>     <meta>         <generated_at>2009-06-19t16:18:40+00:00</generated_at>         <total_entries>1234</total_entries>     </meta>     <entries>         <entry>             <url><![cdata[http://www.example.com/]]></url>             <phish_id>123456</phish_id>             <phish_detail_url>http://www.phishtank.com/phish_detail.php?phish_id=123456</phish_detail_url>             <details>                 <detail>                     <ip_address>1.2.3.4</ip_address>                     <cidr_block>1.2.3.0/24</ip_address>                     <announcing_network>1234</announcing_network>                     <rir>arin</rir>                     <detail_time>2009-06-20t15:37:31+00:00</detail_time>                 </detail>             </details>             <submission>                 <submission_time>2009-06-19t15:15:47+00:00</submission_time>             </submission>             <verification>                 <verified>yes</verified>                 <verification_time>2009-06-19t15:37:31+00:00</verification_time>             </verification>             <status>                 <online>yes</online>             </status>             <target>1st national example bank</target>         </entry>         ...     </entries> </output> 

if want "entry" element value of "example" or other incomplete value how do ?

thank you

var example = xdocument.parse(instr)                    .descendents("entry")                    .where(e => e.element("url").value.contains("example"))                    .firstordefault(); 

if there more 1 possible element may not want .firstordefault()


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -