ARTICLE

How to Use XMLDataSource and How to Append XML in a File

Posted by Biswa Pujarini Mohapatra Articles | XML December 15, 2010
XML is an important format for storing and retrieving data on the web and the reason is it can be moved between firewalls.
Reader Level:

Introduction

XML 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.

<Categories>
  <
Category>
    <
ID>2</ID>
    <Name>xxx</Name>
  </Category>
  <
Category>
    <
ID>3</ID>
    <Name>XYZ</Name>
  </Category>
  <
Category>
    <
ID>4</ID>
    <Name>ABC</Name>
  </Category>
</
Categories>

Bind XMLDataSource to a Repeater

   <asp:Repeater ID="rpt1" runat="server" DataSourceID="XmlDataSource1">
            <HeaderTemplate>
                <table>
                    <tr style="background-color: #000; color: #fff; width: 50%">
                        <td>
                            ID
                        </td>
                        <td>
                            Name
                        </td>
                    </tr>
                </table>
            </HeaderTemplate>
            <ItemTemplate>
                <table>
                    <tr>
                        <td>
                            <%# XPath("ID") %>
                        </td>
                        <td>
                            <%#XPath("Name")%>
                        </td>
                    </tr>
                </table>
                </strong>
            </ItemTemplate>
        </asp:Repeater>
        <asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/XML/XMLFile.xml"
            XPath="Categories/Category"></asp:XmlDataSource>

I am using XLinq to append xml data to a file. By using XLinq we can modify an xml document very easily. Please download the source code to see the example.

Login to add your contents and source code to this article
post comment
     

thanks

Posted by Satyapriya Nayak Dec 15, 2010
COMMENT USING
PREMIUM SPONSORS
DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and add new content to existing PDF documents from within your applications.
Join a Chapter
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.
Get Career Advice from Experts