LINQ Operation XML

Source: Internet
Author: User

XDocument in use will be more simple than XmlDocument, in fact, think is a look for sub-node problems:

1XDocument doc =Xdocument.parse (xmlfile);2XElement root =Doc. Root;3XElement elements = root. Elements ("permition"). Where (U = U.attribute ("name"). Value = =permition). FirstOrDefault ();4   if(Elements = =NULL)5   {6        return false;7   }8XElement Elem = ( fromUinchElements. Descendants ("subpermition")9                          whereU.attribute ("name"). Value = =InfoTen                          Selectu). FirstOrDefault (); One         if(Elem! =NULL) A         { -             return true; -         } the         return false;

1. Locate the parent node and look for all child nodes through the parent node;

2. Match the attribute value corresponding to the child node.

LINQ Operation XML

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.