Basic SelectSingleNode XML Question

N

needin4mation

Hi, Visual Studio created this schema for me:

<xs:schema id="NewDataSet"
targetNamespace="http://tempuri.org/Directions2.xsd"
xmlns:mstns="http://tempuri.org/Directions2.xsd"
xmlns="http://tempuri.org/Directions2.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
attributeFormDefault="qualified" elementFormDefault="qualified">

But I cannot reference it in my code. I tried:

XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
nsmgr.AddNamespace("mstns", "http://tempuri.org/Directions2.xsd");
oldLoc = root.SelectSingleNode("//mstns:NewDataSet/Locations[@agid=1]",
nsmgr);

But it never finds the data. I know it is the namespace because if I
take this line out of my xml file it works (without all the
XmlNamespaceManager problems). XML File:

<?xml version="1.0" encoding="utf-8"?>
<NewDataSet xmlns="http://tempuri.org/Directions2.xsd">

Thanks for any hints.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top