Hi,
Using LINQ with xml files is a breeze, much easier than working with other methods IMO.
But I've run into a bit of a snag with it.
You see, I have an xml file that look like this:
<?xml version="1.0" encoding="utf-8"?>
<merchandiser xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="merchandiser.xsd">
<!-- a list of product nodes exist here -->
</merchandiser>
All is great. In my VB program, I import an xml namespace to use when reading this xml
file, like this:
Imports <xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
So far so good. Now, in code I read the contents of the xml file like this:
Dim xdoc as XDocument = XDocument.Load("C:\merchandiser.xml")
dim brands = from p in xdoc.<xsi:productSelect p.<xsi:brand>.Value
That seems simple enough. However, testing reveals that the "brands" variable contains
absolutely nothing. No error is ever thrown when the code runs.
This is the first time I've worked with a file with two namespaces declared, and I don't
know how to work with both using LINQ.
Can anyone help me?
Roshawn