Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
XPath
Message
General information
Forum:
ASP.NET
Category:
XML
Title:
Re: XPath
Miscellaneous
Thread ID:
00824741
Message ID:
00824884
Views:
21
Hi Nabil,

Your DataSet element belongs to the namespace xmlns=http://tempuri.org/ so if you want to select it from XPath then you need to indicate that this is the namespace which you are matching on. To keep namespaces (which are good) and get your XPath to match you need to add the namespace to your XSLT file and prefix the DataSet element with this namespace prefix. i.e.
<?xml version="1.0" encoding="GB2312"?>
<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:foo="http:tempuri.org" >

 <xsl:template match="/">
  <xsl:apply-templates select="foo:DataSet/NewDataSet/test" />
 </xsl:template>

 <xsl:template match="test">
  <xsl:value-of select="id" />
 </xsl:template>
 </xsl:stylesheet>
>Using WriteXml method, I created an xml file.
>MyDs.WriteXml("MyXml", XmlWriteMode.IgnoreSchema)
>
>The first two lines of MyXml are :
>(?xml version="1.0" standalone="yes" ?)
>(MyDs xmlns="http://www.tempuri.org/MyDs.xsd")
>
>I notice that using XPath for defining parts of an XML document does not return the correct results until I deleted (xmlns="http://www.tempuri.org/MyDs.xsd") from the MyXml.
>
>Any idea why?
-----------------------------------------

Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.com
www.prenia.com
Weblog: blogs.prenia.com/cathi
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform