Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - XPath: SelectSingleNode failing to return node [Thread Next] Re: XPath: SelectSingleNode failing to return nodeTo: NULL Date: 10/21/2008 9:05:00 AM "Bob Barrows [MVP]" <reb01501@N...> wrote in message
news:%23WAhsIuMJHA.2824@T......
>I have this xml which I retrieved from a Sharepoint web service:
> <Views xmlns="http://schemas.microsoft.com/sharepoint/soap/">
> <View Name="{9E45B91C-199C-4403-8331-7F6AE2A30259}" Type="HTML"
> DisplayName="All Items" Url="Lists/Incident Reports/AllItems.aspx"
> BaseViewID="1" />
> <View Name="{5C642326-44D2-4879-9E1D-B47220D88007}" DefaultView="TRUE"
> Type="HTML" DisplayName="Display" Url="Lists/Incident
> Reports/Display.aspx" BaseViewID="1" />
> <View Name="{24E44148-FEEF-4D18-8440-C21593834D28}" Type="HTML"
> Hidden="TRUE" DisplayName="" Url="default.aspx" BaseViewID="1" />
> <View Name="{0BB83D50-7EEE-40C4-B564-8478AD077FA0}" Type="HTML"
> DisplayName="Recent" Url="Lists/Incident Reports/Recent.aspx"
> BaseViewID="1" />
> <View Name="{C33294BE-E0D7-4210-B31C-91C8149242BB}" Type="HTML"
> DisplayName="Dataview" Url="Lists/Incident Reports/Dataview.aspx"
> BaseViewID="1" />
> </Views>
>
> I'm missing something obvious, but I can't figure out why this call to
> SelectSinglenode (in vb.net) fails to return the desired node:
>
> Dim ViewNode As Xml.XmlNode =
> xmldoc.SelectSingleNode("//View[@DisplayName = ""Dataview""]")
> sViewID = ViewNode.Attributes("Name").Value
>
> If I do it the hard way, by looping, it works fine:
>
> For Each xNode In xmldoc.DocumentElement.ChildNodes
> If xNode.Attributes("DisplayName").Value = "Dataview" Then
> sViewID = xNode.Attributes("Name").Value
> Exit For
> End If
> Next
>
> I'm going to move on, using the loop, but I would appreciate if someone
> can tell me what the problem in my xpath query is.
>
>
Look at http://www.dpawson.co.uk/xsl/sect2/N5536.html especially numbers 13
and 23.
You need to use the NamespaceManager and set a prefix mapping such as 'soap'
to "http://schemas.microsoft.com/sharepoint/soap/".
Then use the 'soap'prefix in your paths.
//soap:View[....]
--
Joe Fawcett (MVP - XML)
http://joe.fawcett.name
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
