ASP.NET and XML - PowerPoint PPT Presentation

About This Presentation
Title:

ASP.NET and XML

Description:

XML specification and XML. XML specification is a set of guidelines, ... Professional ASP.NET XML with C# - Wrox publications .NET and XML Niel M. Bornstein ... – PowerPoint PPT presentation

Number of Views:329
Avg rating:3.0/5.0
Slides: 18
Provided by: olddominio
Learn more at: https://www.cs.odu.edu
Category:
Tags: asp | net | xml | wrox

less

Transcript and Presenter's Notes

Title: ASP.NET and XML


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.NETs
    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 Servers 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
  • lt?xml version"1.0" ?gt    ltBankAccountgt
            ltNumbergt1234lt/Numbergt         ltNamegtRama
    n Nairlt/Namegt         ltTypegtCheckinglt/Typegt
            ltOpenDategt11/04/1974lt/OpenDategt
            ltBalancegt25382.20lt/Balancegt
       lt/BankAccountgt

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()

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_id236

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_id236
  • http//www.perfectxml.com/articles/xml/msxml30.asp
    intro
  • http//www.devhood.com/Tutorials/tutorial_details.
    aspx?tutorial_id236

16
  • Questions

17
  • Thank You
Write a Comment
User Comments (0)
About PowerShow.com