i am new guy with XML. this is my XML file content:
<Root>
<COMPANIES>
<id>1</id>
<CompanyName>apple</CompanyName>
<CompanyInCome>450</CompanyInCome>
</COMPANIES>
<COMPANIES>
<id>2</id>
<CompanyName>MS</CompanyName>
<CompanyInCome>458</CompanyInCome>
</COMPANIES>
<COMPANIES>
<id>3</id>
<CompanyName>Evga</CompanyName>
<CompanyInCome>770</CompanyInCome>
</COMPANIES>
<COMPANIES>
<id>4</id>
<CompanyName>GF</CompanyName>
<CompanyInCome>150</CompanyInCome>
</COMPANIES>
</Root>
here i want to find biggest CompanyInCome node and to show on my webpage. How can i make it?
Using Linq-to-XML, you could write something like:
This will return the
<COMPANIES>node which has the highest numerical value in<CompanyInCome>.Update: if you want to read your XML from an external file, use this line of code:
The
.Parse()method is used to parse an existing string of XML defined in your code – it does NOT read from disk.