Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Syntax check - using xpath in repeater efficiently?

Posted on 2008-06-24
2
Medium Priority
?
336 Views
Last Modified: 2013-11-07
Hi,
I finally got my basic syntex working and just wanted to know it I have if completed in the most effiecent way or is there a better /cleaner way that I should look at.  The XML files are pretty small.

<asp:Repeater ID="Repeater1" DataSourceID="XmlSource" runat="server">
  <ItemTemplate>
    <h1><%# Xpath ("../@heading") %></h1>
    <div class="feature">
      <h2>Latest: <%# XPath ("@title") %></h2>
      <img src="<%# XPath ("thumbnail") %>" alt="4wd photo" width="100" height="100"/>
      <p><%# XPath ("summary") %></p>
    <p class="smaller">  
    <%# XPath ("author", "By {0} :: ") %> <%# XPath ("pubDate", "Published: {0}. " ) %>  <%# XPath ("@url","<a href='{0}'>Read more &gt;&gt;</a>" ) %>
    <br class="clearfloat" />    </p>    
    </div>
  </ItemTemplate>
</asp:Repeater>

 <asp:XmlDataSource id="XmlSource" DataFile="/App_Data/articleXML.xml" runat="server" XPath="articles/subject[@category='4wd']/article[feature='yes']" />


<articles>
  <subject category="4wd" heading="4wd Driving Articles">
    <article title="More than Just Rubber" url="/4wd/4wd_tyres_more_than_rubber.asp">
      <feature>yes</feature>
      <pubDate>Jan 2007</pubDate>
      <author>Mick Farmer</author>
      <thumbnail value="yes">/assets/tb_tyre.jpg</thumbnail>
      <summary>I was inspired to revisit this subject by a "late night" conversation with friends who had just fitted cross ply tyres to their vehicles without realising it.</summary>
    </article>
    <article title="Winches - Do You Need One?" url="/4wd/4wd_winches.asp">
      <feature>no</feature>
      <pubDate>Nov 2005</pubDate>
      <updated value="true">Feb 2008</updated>
      <author>Mick Farmer</author>
      <thumbnail value="yes">/assets/tb_winch.jpg</thumbnail>
      <summary>Picking recovery equipment for your vehicle is a bit like selecting a 4wd. First, you need to examine where, when and what are you going to be doing - then select the equipment most suitable.</summary>
    </article>
....

I will try to move towards Linq in the next few months but finding it tough after finally understanding xpath (a little!).  But for now ...

Cheers
Tania

0
Comment
Question by:Tania_Farmer
2 Comments
 
LVL 3

Accepted Solution

by:
maliger earned 750 total points
ID: 21856129
I don't see anything wrong or inefficient in your solution. Nice job!
0
 

Author Comment

by:Tania_Farmer
ID: 21862940
Thanks.
Tania
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Screencast - Getting to Know the Pipeline
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question