|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
|
Announcements
Want a new Job?
Chapters
Services
Feature Zones
|
IntroductionXML is an important format for storing and retrieving data on the web and the reason is it can be moved between firewalls. We see many websites with RSS and XML output. Many visitors use them to save their time and increase their speed for viewing their favorite websites and web logs. As a developer you should know that Visual Studio .NET 2005 helps you to work with XML data with its new Using this new control you can insert, delete and update XML data easily in minimum amount of time. In this article I'm going to show you how to use this new control and describe its common properties and features. I'll try to show these features in ASP.NET because this new control is more applicable on the web. Local XML fileFirst we need to create this XML file before using our new control: (XMLFile.xml) <?xml version="1.0" encoding="utf-8" ?>
<IranHistoricalPlaces>
<Place name="Taghe Bostan">
<City>Kermanshah</City>
<Antiquity>2000</Antiquity>
</Place>
<Place name="Persepolis">
<City>Shiraz</City>
<Antiquity>2500</Antiquity>
</Place>
</IranHistoricalPlaces>
Now I use the following code to show my XML file data in a <asp:Repeater ID="Repeater" runat="server" DataSourceID="XmlDataSource">
<ItemTemplate>
<Strong><%# XPath("@name") %><br /></Strong>
<%#XPath("City")%><br />
<%#XPath("Antiquity")%><br />
</ItemTemplate>
</asp:Repeater>
<asp:XmlDataSource ID="XmlDataSource" runat="server" DataFile="~/XMLFile.xml"
XPath="IranHistoricalPlaces/Place">
</asp:XmlDataSource>
In the above code, first I add the Now I try to set up my The final result is shown in the following figure:
XML file on the webWe aren't limited to using local XML files. We can use XML files on the web to show in our Web Forms (and it's the major application of this new data control). Assume that you want to use your favorite RSS in your Web Form. I'll show you how you can do this. Insert another <asp:XmlDataSource ID="XmlDataSource" DataFile="http://nayyeri.net/rss.aspx"
XPath="rss/channel/item" runat="server"></asp:XmlDataSource>
<asp:DataList ID="DataList" runat="server" DataSourceID="XmlDataSource">
<ItemTemplate>
<font face="tahoma" size="6"><Strong><%#XPath("title")%><br />
</Strong></font>
<%#XPath("description")%><br />
<font color="navy"><i><%#XPath("pubDate")%><br /></i></font>
</ItemTemplate>
</asp:DataList>
I wanted to load my post title, description and publish the date in this Web Form. So I set the Here you can see the final result:
The last point about <asp:XmlDataSource ID="XmlDataSource" DataFile="http://nayyeri.net/rss.aspx"
XPath="rss/channel/item" runat="server"></asp:XmlDataSource>
<asp:DataList ID="DataList" runat="server" DataSourceID="XmlDataSource">
<ItemTemplate>
<font face="tahoma" size="6"><Strong><I><%#XPath("title")%></I><br />
</Strong></font>
<%#XPath("description")%><br />
<font color="navy"><i><%#XPath("pubDate")%><br /></i></font>
</ItemTemplate>
</asp:DataList>
Additional informationThese are common applications of The Smart tagSmart tags are very useful in ASP.NET 2. So, I'll try to describe the
Using the first choice (Configure Data Source) you can configure important properties of your The second choice is simple. It's just for refreshing control schema. BugsThere is an important bug in this control and you can read the full story here. Probably Microsoft will fix it in the RTM version. History
|
||||||||||||||||||||||