O'Reilly logo

Visual Basic 2008 Recipes: A Problem-Solution Approach by Rakesh Rajan, Matthew MacDonald, Allen Jones, Todd Herman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

7.7. Query for Elements in a Specific XML Namespace

Problem

You need to filter the contents of or find specific elements in an XML document that belong to a specific XML namespace.

Solution

Define any appropriate namespaces, and then perform your query using any of the clauses available in System.Xml.Linq, ensuring that you specify the appropriate namespace to use.

How It Works

As with the .NET Framework itself, XML namespaces are used to separate elements into groups. Every XElement object in an XML tree contains an XName object, which in turn contains an XNamespace object. If you have XML that contains information from multiple sources or related to multiple entities, using namespaces provides an appropriate mechanism for dividing the information ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required