What is best way to search in XML document to retrieve one or more records against search criteria. Suggestions are welcomed.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Personally I’d use LINQ to XML if you possibly can. Your question is very vague at the moment, but for example, you could write:
While you can use XPath, I generally prefer not to – it has all the normal problems of embedding one language within another, whereas using LINQ to XML you’re using C# throughout, so you have no new syntax to learn – just the relevant methods within the LINQ to XML library.
LINQ to XML also makes namespace handling simple, and you don’t need to worry about escaping values etc, as your query is all in code rather than in a string.