G
Guest
i got a xml file which is using a namespace declaration with no prefix, as
you can see here
----
<?xml version="1.0" encoding="utf-8"?>
<configuration
xmlns="http://www.microsoft.com/schema/EnterpriseInstrumentation/v1/EnterpriseInstrumentation.xsd">
<instrumentedApp name="SimpleInstrumentation" mode="released" />
----
when i use the following xpath expression
"/configuration/instrumentedApp/@name"
in order to get the atributte named "name" of the element named
"instrumentedApp", using the following code
----
XmlReader objXmlReader = new XmlTextReader(objFileStream);
System.Xml.XPath.XPathDocument objXPathDocument = new
XPathDocument(objXmlReader);
System.Xml.XPath.XPathNavigator objXPathNavigator =
objXPathDocument.CreateNavigator();
string result = string.Empty;
XPathNodeIterator objXPathNodeIterator =
objXPathNavigator.Select("/configuration/instrumentedApp/@name");
if (objXPathNodeIterator.MoveNext())
result = objXPathNodeIterator.Current.Value.Trim();
----
it simple does not work, because the i have to indicate the namespace scope
of the element.
¿how can i do that?
thanks
you can see here
----
<?xml version="1.0" encoding="utf-8"?>
<configuration
xmlns="http://www.microsoft.com/schema/EnterpriseInstrumentation/v1/EnterpriseInstrumentation.xsd">
<instrumentedApp name="SimpleInstrumentation" mode="released" />
----
when i use the following xpath expression
"/configuration/instrumentedApp/@name"
in order to get the atributte named "name" of the element named
"instrumentedApp", using the following code
----
XmlReader objXmlReader = new XmlTextReader(objFileStream);
System.Xml.XPath.XPathDocument objXPathDocument = new
XPathDocument(objXmlReader);
System.Xml.XPath.XPathNavigator objXPathNavigator =
objXPathDocument.CreateNavigator();
string result = string.Empty;
XPathNodeIterator objXPathNodeIterator =
objXPathNavigator.Select("/configuration/instrumentedApp/@name");
if (objXPathNodeIterator.MoveNext())
result = objXPathNodeIterator.Current.Value.Trim();
----
it simple does not work, because the i have to indicate the namespace scope
of the element.
¿how can i do that?
thanks