From the course: .NET Essentials: LINQ for XML

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Get nodes when using schema namespace

Get nodes when using schema namespace - .NET Tutorial

From the course: .NET Essentials: LINQ for XML

Start my 1-month free trial

Get nodes when using schema namespace

- [Instructor] There is an additional step necessary when you want to get an element that is in a file that has a schema specified within a namespace. Now, I'm looking at this file, BigStarCollectibles. You can see in my root element, Collectibles, I have a default namespace specified here. It has no prefix. This is called the default namespace. And then I provide this unique URI here. So it's bigstarcollectibles.com/course-examples. So if I want to get to this card element, I need to specify this namespace too. So over here, in LINQPad, I am loading BigStarCollectibles.xml that I'm specifying on line eight this variable of type X namespace, and you can see that the matches what I showed you over in the XML file. And then it's just a matter of concatenating the two together. So when I call dot element, I can concatenate these two together. This is the name of the element I want. And when I run this, I get the results I want.…

Contents