Skip to main content

Posts

Showing posts with the label xml

ASP .NET - XML Files

An XML File Here is an XML file named "countries.xml": <?xml version="1.0" encoding="ISO-8859-1"?> <countries> <country>   <text>Norway</text>   <value>N</value> </country> <country>   <text>Sweden</text>   <value>S</value> </country> <country>   <text>France</text>   <value>F</value> </country> <country>   <text>Italy</text>   <value>I</value> </country> </countries> Bind a DataSet to a List Control First, import the "System.Data" namespace. We need this namespace to work with DataSet objects. Include the following directive at the top of an .aspx page: <%@ Import Namespace="System.Data" %> Next, create a DataSet for the XML file and load the XML file into the DataSet when the page is first loaded: <script runat="server"> sub Page_Load if Not Page.IsPos...

Generate dynamic ASP.NET pages by using XML and XSLT

Introduction Sometimes you need to create dynamic pages. You may allow users to build their own applications by selecting the fields they need. In this article, I will show how to build dynamic applications by using ASP.NET and XML . In this example, I use XML for meta-programming or generative programming. I use XML with an XSLT to generate ASP.NET PRE, utilizing intrinsic ASP.NET parsing methods with the XSLT output. Steps that we need to do: Create XML file (schema of our page). Create an XSLT style to transform XML into ASP.NET PRE. Transform XML , and create server controls defined by the generated ASP.NET PRE at runtime. Insert the instantiated controls into the page's control collection. Handle postback events from server controls. First, what we need to come up with is a good structure of our page in a XML file. A basic page structure is defined below. The example structure consists of field elements, with attributes, properties and listitems. Collapse ...

Using XML in ASP.NET

XML is a cross-platform, hardware and software independent, text based markup language, which enables you to store data in a structured format by using meaningful tags. XML stores structured data in XML documents that are similar to databases. Notice that unlike Databases , XML documents store data in the form of plain text, which can be used across platforms. In an XML document, you specify the structure of the data by creating a DTD or an XML schema. When you include a DTD in an XML document, the software checks the structure of the XML document against the DTD. This process of checking the structure of the XML document is called validating . The software performing the task of validating is called a validating parser. The following code defines the structure of an XML document that will store data related to books: <? xml version = " 1.0 " ?> < Books >   < Book bid = " B001 " >     < Title > Understanding XML </ Title ...