If you have a look at your XML (just the first few lines):
<VacancyList generated="2009-08-04T18:43:17"
xmlns="urn:EasyCruit"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.easycruit.com/dtd/vacancy-list.xsd">
<Vacancy id="82034" date_start="2007-04-17" date_end="2009-12-22"
reference_number="CDP-GR3">
<Versions>
<Version language="fr">
<Title>Chef de produit (H/F)</Title>
<TitleHeading/>
You bind your datagrid to the list of <Vacancy>
elements - fine so far.
But then in your grid, you reference : <%# XPath( "Version/Title" ) %>
This won't work, since the <Vacancy>
does not have a '/ inside it - these elements are within a
` collection.....
So what you need to reference in your ItemTemplate would be:
<%# XPath( "Versions/Version[@language='fr']/Title" ) %>
That should work.
UPDATE:
there appears to be an additional problem with the ASP.NET 2.0 XmlDataSource not being able to handle default XML namespaces :-(
That's this line here in your XML:
<VacancyList ........
xmlns="urn:EasyCruit"
See this blog post here on the topic: http://jasonf-blog.blogspot.com/2006/08/xmldatasource-xpath-workaround-for.html
There's really two things you could do to fix this:
- use an XSLT transformation to strip out the default namespace so that the XmlDataSource can handle the data
- load the data from the URL in code, and bind it to the GridView in your code-behind
UPDATE 2:
The method of stripping out the XML namespaces seems to work quite nicely - Bill Evjen proposes this method here.
If you save his XSLT file in the post to a file called "StripNamespaces.xslt" in the web site project, you should get your data if you change the asp:XmlDataSource to be:
<asp:XmlDataSource ID="XMLsource" runat="server"
DataFile="http://demo.easycruit.com/export/xml/vacancy/list.xml"
TransformFile="~/StripNamespaces.xslt"
XPath="VacancyList/Vacancy" />
Note the new "TransformFile" setting - this must reference that XSLT file. With this in place, I am now getting data displayed in the GridView.
Marc