Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Syntax check - using xpath in repeater efficiently?

Posted on 2008-06-24
2
Medium Priority
?
334 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Quick Start: DOCKER

Sometimes you just need a Quick Start on a topic in order to begin using it.. this is just what you need to know to get up and running with Docker!

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 …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

730 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