tags:

views:

107

answers:

1

Hi ,

i have got a news section in my website. I can Insert news to my XML file , than shows them in main page.There are so many news in my xml file.I showing them with Xpath("content") command.So i can restrict item count with xPath command.Is there anyway to Paging or Max Items option for this usage ?

XML File;

<?xml version="1.0" encoding="utf-8" ?>
<newsSection>
  <news>
    <header>Haber Deneme </header>
    <content> In ASP I found navigating an XML file without actually seeing it was extremely difficult and ASP.NET didn't help much. ASP.NET has several objects that you can use to browse an XML file, after much searching, exploring and experimenting I found that the XMLTextReader was the best one for the job (and the one that didn't give me as many annoying error messages). Someone should really create a visual XML to ASP.NET creator.</content>
    <imagepath>img/deneme.jpg</imagepath>
    <date>30.01.2010</date>
  </news>

</newsSection>

and my code file ;

<div class="orta_taraf_icerik">
    <asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/news.xml">
    </asp:XmlDataSource>
    <asp:DataList ID="DataList1" runat="server" DataSourceID="XmlDataSource1">
    <ItemTemplate>
    <div class="news">
    <h1><%#XPath("header") %> </h1><bR /> 
   <img src='<%#XPath("imagepath") %>' /> <%#XPath("content") %><br /><br />
   <span class="tarih"><%#XPath("date") %> - Manisa Bölge İdare Mahkemesi</span>
    </div>
    </ItemTemplate>
    </asp:DataList>
    </div>
+1  A: 

Assuming your XML is in the format:

<newsSection>
  <news>
    ...
  </news>
  <news>
    ...
  </news>
</newsSection>

You can try using the following XPath:

<asp:XmlDataSource XPath="newsSection/news[position() < 6]" ...
Dror
thanx man , is there any way to Paging after 5 item ?
Ibrahim AKGUN
No problem!For paging see http://forums.asp.net/p/1108198/1845104.aspx
Dror