Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
XPath
Message
Information générale
Forum:
ASP.NET
Catégorie:
XML
Titre:
Re: XPath
Divers
Thread ID:
00824741
Message ID:
00825007
Vues:
22
Thank you Cathi, the article was really helpful.


>Nabil,
>
>Check out this link that gives you an example of how to use XPath and namespaces:
>
>http://samples.gotdotnet.com/quickstart/howto/doc/Xml/XmlNameSpace.aspx
>
>
>>Where to indicate the namespace in XPath?
>>
>>Dim xmlnl As XmlNodeList
>>xmlnl = myDoc.SelectNodes("/MyDs/Table1[Field1=...]")
>>
>>
>>>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?
System Analyst
Nabil B. Ghrayyeb
nabilg@hotmail.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform