Working With XML Data and Search Tool
Working With XML Data and Search Tool
Working With XML Data and Search Tool
Overview of Session
Introducing XML Working with XML Server Control Converting Relational Data into XML documentXml DataSource
XML
XML stands for EXtensible Markup Language XML is a markup language much like HTML XML was designed to describe data XML tags are not predefined. You must define your own tags
Xml Control
The Xml control can be used to write out an XML document The DocumentSource specifies the XML document to use TransformSource specifies the XSLT file
XSL
XSL is the preferred style sheet language of XML. XSL (the eXtensible Stylesheet Language) is far more sophisticated than CSS. One way to use XSL is to transform XML into HTML before it is displayed by the browser as demonstrated in these examples:
XML File
<?xml version="1.0" encoding="utf-8" ?> <Employees> <Employee> <Name>Priya</Name> <Address>Noida</Address> <Department>Admin</Department> </Employee> <Employee> <Name>Pooja</Name> <Address>Noida</Address> <Department>HR</Department> </Employee> </Employees>
XSLT File
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <body> <table border="2"> <tr bgcolor="pink"> <td>Name</td> <td>Address</td> <td>Dept</td> </tr> <xsl:for-each select="Employees/Employee"> <tr> <td><xsl:value-of select="Name"></xsl:value-of> <td><xsl:value-of select="Address"></xsl:value-of> <td><xsl:value-of select="Department"></xsl:value-of> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet>
Output..
XMLDataSource The XmlDataSource control is a data source control that presents XML data to data-bound controls The XmlDataSource typically loads XML data from an XML file
Restrictions
There are some restrictions to the editing capabilities of the XmlDataSource control: The XML data must be loaded from an XML file that is indicated by the DataFile property, not from inline XML specified in the Data property. No XSLT transformation can be specified in the Transform or TransformFile properties. The Save method does not handle concurrent save operations by different requests. If more than one user is editing an XML file through the XmlDataSource, there is no guarantee that all users are operating with the same data. It is also possible for a Save operation to fail due to these same concurrency issues.
XMLDataSource
Capability
Sorting
Description
Not supported by the XmlDataSource
control.
Filtering
The XPath property can be used to filter the XML data using an appropriate XPath expression.
Paging
Updating, Deleting,Inserting
Supported by manipulating the XmlDataDocument directly and then calling the Save method.