Download presentation
Presentation is loading. Please wait.
Published byEdwin Lamb Modified over 9 years ago
1
ASP.NET and XML Presented By: Shravan S. Mylavarapu 1
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 2
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. 3
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 4
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. 5
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 6
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 7
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. 8
9
XmlWriter and XMLReader using System.Xml; 1234 Raman Nair Checking 11/04/1974 25382.20 9
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.Flush(); 10
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()); } } } 11
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 12
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. 13
14
XML Serialization (contd…) XMLSerializer class – Serialize and Deserialize methods http://msdn2.microsoft.com/en- us/library/182eeyhh.aspx http://msdn2.microsoft.com/en- us/library/182eeyhh.aspx Examples: – http://msdn2.microsoft.com/en- us/library/58a18dwa.aspx http://msdn2.microsoft.com/en- us/library/58a18dwa.aspx – http://www.devhood.com/Tutorials/tutorial_details.as px?tutorial_id=236 http://www.devhood.com/Tutorials/tutorial_details.as px?tutorial_id=236 14
15
References Professional ASP.NET XML with C# - Wrox publications.NET and XML – Niel M. Bornstein http://www.perfectxml.com/articles/xml/msxml30.asp#int ro http://www.perfectxml.com/articles/xml/msxml30.asp#int ro http://www.devhood.com/Tutorials/tutorial_details.aspx? tutorial_id=236 http://www.devhood.com/Tutorials/tutorial_details.aspx? tutorial_id=236 http://www.perfectxml.com/articles/xml/msxml30.asp#int ro http://www.perfectxml.com/articles/xml/msxml30.asp#int ro http://www.devhood.com/Tutorials/tutorial_details.aspx? tutorial_id=236 http://www.devhood.com/Tutorials/tutorial_details.aspx? tutorial_id=236 15
16
Questions 16
17
Thank You 17
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.