Solved

Syntax check - using xpath in repeater efficiently?

Posted on 2008-06-24
2
328 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 250 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

863 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now