Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


XPath: SelectSingleNode failing to return node

From: "Bob Barrows [MVP]" <reb01501@-------.------->
To: NULL
Date: 10/20/2008 2:32:00 PM
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.




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent