1 / 17

ASP.NET and XML

ASP.NET and XML. Presented By: Shravan S. Mylavarapu. Overview. Introduction to XML ASP.NET Web Development The Role of XML in ASP.NET XML Integration in ASP.NET Processing XML XMLWriter and XMLReader Xpath XML Serialization. Introduction to XML. XML specification and XML

brandi
Download Presentation

ASP.NET and XML

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ASP.NET and XML Presented By: Shravan S. Mylavarapu

  2. Overview • Introduction to XML • ASP.NET Web Development • The Role of XML in ASP.NET • XML Integration in ASP.NET • Processing XML • XMLWriter and XMLReader • Xpath • XML Serialization

  3. Introduction to XML XML specification and XML XML specification is a set of guidelines, defined by the World Wide Web Consortium (W3C), for describing structured data in plain text. XML is a markup language (like HTML) based on tags within angled brackets, and is also a subset of SGML (Standard Generalized Markup Language). The textual nature of XML makes the data highly portable and broadly deployable. XML does not have a fixed set of tags. The ability to create new tags makes XML a truly extensible language.

  4. ASP.NET Web Development ASP.NET represents the next generation of web development on the Windows platform. ASP.NET includes many new features related to Web Forms, such as deployment, state management, caching, configuration, debugging, data access as well as Web Services. We will focus on XML features of ASP.NET

  5. The Role of XML in ASP.NET • .NET Framework makes use of XML internally in many situations and thus it allows XML to be easily used from our applications. • XML pervades the entire Framework, and ASP.NET’s XML integration can be used to build highly extensible web sites and Web Services.

  6. XML Integration in ASP.NET • The System.Xml Namespace • Create and process XML documents using streaming API or DOM • Query XML documents • Transform XML documents • Validate XML documents • Web Services • ASP.NET Web Services are programmable logic that can be accessed from anywhere on the Internet, using HTTP(GET/POST/SOAP) and XML

  7. XML Integration in ASP.NET (contd…) • SQLXML Managed Classes • Allow access to SQL Server’s native and extended XML features. • The ADO.NET DataSet Class • Can be serialized as XML and conversely, populated from XML • The .config Files • Web.config • C# Code Documentation • /// Used to document the source code with XML tags

  8. Processing XML • Document Object Model • Using DOM, the parser loads the entire XML document into the memory at once as a tree, providing random access to it for searching and modifying any element in the document. • Simple API for XML (SAX) • SAX follows a streaming model, reading an XML document character by character as a stream and generating events as each element or attribute is encountered.

  9. XmlWriter and XMLReader • using System.Xml; • <?xml version="1.0" ?>    <BankAccount>         <Number>1234</Number>         <Name>Raman Nair</Name>         <Type>Checking</Type>         <OpenDate>11/04/1974</OpenDate>         <Balance>25382.20</Balance>    </BankAccount>

  10. XmlWriter XmlTextWriter bankWriter = null; bankWriter = new XmlTextWriter (m_strFileName, null); bankWriter.Formatting = Formatting.Indented; bankWriter.Indentation= 6; bankWriter.Namespaces = false; bankWriter.WriteStartDocument(); bankWriter.WriteStartElement("", "BankAccount", ""); bankWriter.WriteStartElement("", “Balance", ""); bankWriter.WriteString("1234"); bankWriter.WriteEndElement(); bankWriter.WriteStartElement("", "Name", ""); bankWriter.WriteString("Darshan Singh"); bankWriter.WriteEndElement(); bankWriter.WriteEndElement(); bankWriter.Flush();

  11. XmlReader XmlTextReader bankReader = null;  bankReader = new XmlTextReader (m_strFileName);       while (bankReader.Read())       {          if (bankReader.NodeType == XmlNodeType.Element)             {                if (bankReader.LocalName.Equals("Name"))                {                   Console.Write("{0} has balance of $", bankReader.ReadString());                }                if (bankReader.LocalName.Equals("Balance"))                {                   Console.WriteLine("{0}", bankReader.ReadString());                }             }          }

  12. XPath • XPath is a standard language for retreiving data in XML document. • System.Xml.XmlNode • System.Xml.XPath.XPathDocument • System.Xml.Xpath.XPathNavigator • Example: /BankAccount/Number

  13. XML Serialization • Serialization is the process of converting an object into a form that can be readily transported. For example, you can serialize an object and transport it over the Internet using HTTP between a client and a server. On the other end, deserialization reconstructs the object from the stream. • XML serialization serializes only the public fields and property values of an object into an XML stream. XML serialization does not include type information. For example, if you have a Book object that exists in the Library namespace, there is no guarantee that it will be deserialized into an object of the same type.

  14. XML Serialization (contd…) • XMLSerializer class • Serialize and Deserialize methods • http://msdn2.microsoft.com/en-us/library/182eeyhh.aspx • Examples: • http://msdn2.microsoft.com/en-us/library/58a18dwa.aspx • http://www.devhood.com/Tutorials/tutorial_details.aspx?tutorial_id=236

  15. References • Professional ASP.NET XML with C# - Wrox publications • .NET and XML – Niel M. Bornstein • http://www.perfectxml.com/articles/xml/msxml30.asp#intro • http://www.devhood.com/Tutorials/tutorial_details.aspx?tutorial_id=236 • http://www.perfectxml.com/articles/xml/msxml30.asp#intro • http://www.devhood.com/Tutorials/tutorial_details.aspx?tutorial_id=236

  16. Questions

  17. Thank You

More Related