read attribute value within a attribute using XPathNavigator

This is how my xPathNavigator looks like:

<mux:Column Name="id" DisplayMemberBinding="{Binding Path=Id, Mode=OneWay}" Width="100" DisplayName="Header_Id" Property="Id" DataType="s:String" xmlns:mux="http://schemas.microsoft.com/SystemCenter/Common/UI/Views/GridView" />

I want to read the value of Path in the DisplayMemberBinding attribute.

This is what i have tried:

xPathNavigator.GetAttribute("DisplayMemberBinding", "") //Gives me {Binding Path=Id, Mode=OneWay}

xPathNavigator.GetAttribute("DisplayMemberBinding/Binding/@Path", "") //Gives me empty string

How do i get to the value of Path in DisplayMemberBinding attribute?

Answers


Use:

xPathNavigator.Evaluate
  (@"substring-before(substring-after(@DisplayMemberBinding, 'Path='),
                     ',')"
  );

Of course, you need to cast the result to string.

XSLT-based verification:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:mux="http://schemas.microsoft.com/SystemCenter/Common/UI/Views/GridView">
 <xsl:output omit-xml-declaration="yes" indent="yes"/>

 <xsl:template match="/*">
  <xsl:value-of select=
  "substring-before(substring-after(@DisplayMemberBinding, 'Path='),
                    ',')"/>
 </xsl:template>
</xsl:stylesheet>

When this transformation is applied on the provided XML document:

<mux:Column Name="id"
DisplayMemberBinding="{Binding Path=Id, Mode=OneWay}"
Width="100" DisplayName="Header_Id"
Property="Id" DataType="s:String"
xmlns:mux="http://schemas.microsoft.com/SystemCenter/Common/UI/Views/GridView" />

the XPath expression is evaluated and the result of this evaluation is copied to the output:

Id

Need Your Help

Redirect user to another page when he likes a page tab

php facebook api

I had this block of code working but not anymore...

Funny Thread Behaviour in Scala

java multithreading scala

I'm making some experiments to try and understand Threads in practice. Please look at the following snippet: It's a main function that spawns a thread listening on port 2020. This thread, in turn,

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.