WORKING WITH XML IN THE.NET FRAMEWORK. Accessing an XML File Basic activities: open it, read it.NET Framework provides structured and unstructured mechanisms.

Slides:



Advertisements
Similar presentations
Copyright © 2003 Pearson Education, Inc. Slide 8-1 Created by Cheryl M. Hughes, Harvard University Extension School Cambridge, MA The Web Wizards Guide.
Advertisements

The Document Object Model
XML: Extensible Markup Language
XML CS What is XML?  XML: a "skeleton" for creating markup languages  you already know it!  syntax is identical to XHTML's: content  languages.
Document Object Model. Lecture 18 The Document Object Model (DOM) is not a programming language It is an object-oriented model of web documents Each.
Document Object Model (DOM): An Abstract Data Structure for XML data Alex Dekhtyar Department of Computer Science University of Kentucky.
PHP and the DOM There was some experimental support for the DOM in PHP 4 But it is only with PHP 5 that support appears to have stabilized At present,
XML DOM and SAX Parsers By Omar RABI. Introduction to parsers  The word parser comes from compilers  In a compiler, a parser is the module that reads.
Document Object Model (DOM): An Abstract Data Structure for XML data Alex Dekhtyar Department of Computer Science CSC 560: Management of XML Data.
CSE 154 LECTURE 23: XML. Storing structured data in arbitrary text formats (bad) My note: BEGIN FROM: Alice Smith TO: Robert Jones.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Cos 381 Day 10.
C# The new language for Updated by Pavel Ježek © University of Linz, Institute for System Software, 2004 published under the Microsoft Curriculum License.
.NET and XML (or XML in.NET) David Oguns Matt Harding.
Svetlin Nakov Telerik Software Academy Manager Technical Training DOM Parser, Streaming Parser, XPath, LINQ to.
XML files (with LINQ). Introduction to LINQ ( Language Integrated Query ) C#’s new LINQ capabilities allow you to write query expressions that retrieve.
XML Fundementals XML vs.. HTML XML vs.. HTML XML Document (elements vs. attributes) XML Document (elements vs. attributes) XML and RDBMS XML and RDBMS.
The Document Object Model (DOM) & Asynchronous Javascript And XML (AJAX) : an introduction UFCEKG-20-2 : Data, Schemas and Applications.
CSE 154 LECTURE 24: XML AND JSON. Debugging responseXML in Firebug can examine the entire XML document, its node/tree structure.
XML C#.NET Software Development. eXtensible Markup Language Markup language that describes data Markup language that describes data Stores data as text.
1 Fall 2006 Florida Atlantic University Department of Computer Science & Engineering COT 6930 Advanced Internet Programming Dr. Roy Levow Day 2.
1 XML Data Management 4. Domain Object Model Werner Nutt.
JS: Document Object Model (DOM)
5 Processing XML Parsing XML documents  Document Object Model (DOM)  Simple API for XML (SAX) Class generation Overview.
1 Using XML in.NET Sorting through the choices. 2 XML and API’s XML is a series of W3C recommendations Focus on structure and behavior W3C says very little.
Presentation XML. NET SEMINAR By: Siddhant Ahuja (SID)
ASP.NET and XML Presented By: Shravan S. Mylavarapu 1.
JavaScript & DOM Client-side scripting. JavaScript JavaScript is a tool to automate client side (which is implemented using HTML so far) JavaSript syntax.
D2L Notes Be sure to submit your link in the dropbox provided on D2L You can just upload an empty text file if a file upload is required Do not use D2L.
Parsing with DOM using MSXML Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
DOM Robin Burke ECT 360. Outline XHTML in Schema JavaScript DOM (MSXML) Loading/Parsing Transforming parameter passing DOM operations extracting data.
Fall 2006 Florida Atlantic University Department of Computer Science & Engineering COP 4814 – Web Services Dr. Roy Levow Part 4 - XML.
Working with the XML Document Object Model ©NIITeXtensible Markup Language/Lesson 7/Slide 1 of 44 Objectives In this lesson, you will learn to: *Identify.
The XML Document Object Model (DOM) Aug’10 – Dec ’10.
 2004 Prentice Hall, Inc. All rights reserved. 1 Chapter 34 - Case Study: Active Server Pages and XML Outline 34.1 Introduction 34.2 Setup and Message.
Client side web programming Introduction Jaana Holvikivi, DSc. School of ICT.
XML DOM Functionality in.NET DSK Chakravarthy
5.2 DOM (Document Object Model). 2 Motto: To write it, it took three months; to conceive it three minutes; to collect the data in it — all my life. —F.
DAT 379 XML Today And Tomorrow Mark Fussell Lead Program Manager Microsoft Corporation.
Module 7: Accessing Data by Using ADO.NET
JavaScript IV ECT 270 Robin Burke. Outline DOM JS document model review W3C DOM.
Declaratively Producing Data Mash-ups Sudarshan Murthy 1, David Maier 2 1 Applied Research, Wipro Technologies 2 Department of Computer Science, Portland.
Accessing Data Using XML CHAPTER NINE Matakuliah: T0063 – Pemrograman Visual Tahun: 2009.
C# and Windows Programming XML Processing. 2 Contents Markup XML DTDs XML Parsers DOM.
1 Dr Alexiei Dingli XML Technologies SAX and DOM.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.2 Revised by Dr. T. Tran for CSI3140.
Introduction to the Document Object Model Eugenia Fernandez IUPUI.
Markup basics. Markup languages add commentary to text files –so that the commentary can be ignored if not understood eg HyperText Markup Language –adds.
 2008 Pearson Education, Inc. All rights reserved Document Object Model (DOM): Objects and Collections.
.NET and XML (or XML in.NET) Matt Harding David Oguns.
XML DOM.
Advanced DOM Builds on last presentation on DOM Allows you to dynamically create elements and position them on a page DOM methods/properties are W3C standard.
Working with Elements and Attributes Using DOM Eugenia Fernandez IUPUI.
Create Element, Remove Child. The Document Tree Document Element Root Element Element Element Element Element Text: HelloWorld Attribute “href”
JS: Document Object Model (DOM) DOM stands for Document Object Model, and allows programmers generic access to: DOM stands for Document Object Model, and.
XML DOM  XML Document Object Model provides a robust international standard for XML Documents.  DOM Level 1 is a Dec 11, 1998 W3C recommendation.  XML.
CHAPTER NINE Accessing Data Using XML. McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc. All rights reserved Introduction The eXtensible.
Data Access. ADO.NET ADO.NET is the primary library for building database solutions within the.NET Framework. ADO.NET does not replace ADO. ADO and OLEDB.
XML CS What is XML?  XML: a "skeleton" for creating markup languages  you already know it!  syntax is identical to XHTML's: content  languages.
THE DOM.
XML for .NET Session 1 Introduction to XML Introduction to XSLT
XML: Extensible Markup Language
CSE 154 Lecture 12: XML.
Scripting the DOM MIS 3502, Fall 2016 Jeremy Shafer Department of MIS
Applied Online Programming
Introduction to the Document Object Model
Geoffrey Fox and Bryan Carpenter PTLIU Laboratory for Community Grids
DOM Document Object Model.
Processing XML.
DOM & SAX XML & ADO.NET GVTH: Phạm Anh Phương
XML DOM and CSS Instructors: Geoffrey Fox and Bryan Carpenter
Presentation transcript:

WORKING WITH XML IN THE.NET FRAMEWORK

Accessing an XML File Basic activities: open it, read it.NET Framework provides structured and unstructured mechanisms for processing XML files i.e.: stream of data, or hierarchical structure Basic activities: open it, read it.NET Framework provides structured and unstructured mechanisms for processing XML files i.e.: stream of data, or hierarchical structure

XML Classes We Will Use XmlReader - process as you go XmlNode – represents nodes in an XML file XmlDocument – represents entire XML document XmlDataDocument – data enabled XmlReader - process as you go XmlNode – represents nodes in an XML file XmlDocument – represents entire XML document XmlDataDocument – data enabled

Delaney, Kalen Inside Microsoft SQL Server Microsoft Press Burton, Kevin.NET Common Language Runtime Sams Cooper, James W. C# Design Patterns Addison Wesley Hull, Dale E. The Joys of SOA and Web Services With.NET Fulfilled Life Press Guy, Class E. Dressing For Success As A.NET Developer Gentleman's Quarterly Delaney, Kalen Inside Microsoft SQL Server Microsoft Press Burton, Kevin.NET Common Language Runtime Sams Cooper, James W. C# Design Patterns Addison Wesley Hull, Dale E. The Joys of SOA and Web Services With.NET Fulfilled Life Press Guy, Class E. Dressing For Success As A.NET Developer Gentleman's Quarterly

Document Object Model (DOM) Internet standard for representing the information contained in an HTML or XML file as a tree of nodes.NET Framework supports Level 1 core specs and Level 2 core specs It extends the specifications by adding objects, methods and properties not defined in the spec Internet standard for representing the information contained in an HTML or XML file as a tree of nodes.NET Framework supports Level 1 core specs and Level 2 core specs It extends the specifications by adding objects, methods and properties not defined in the spec

XML Document Structure Series of nested items, including elements and attributes Any nested structure can be transformed into an equivalent tree structure if the outermost nested item is made the root of the tree The next nested items are children of the root, etc. Series of nested items, including elements and attributes Any nested structure can be transformed into an equivalent tree structure if the outermost nested item is made the root of the tree The next nested items are children of the root, etc.

The XmlReader Class Forward-only, read-only access to an XML file Similar to a cursor in processing a relational database Move through the file with Read() Read() returns the next node Forward-only, read-only access to an XML file Similar to a cursor in processing a relational database Move through the file with Read() Read() returns the next node

Important Properties of XmlReader Depth EOF HasAttributes IsEmptyElement Name NodeType Value Depth EOF HasAttributes IsEmptyElement Name NodeType Value

Important Methods of XmlReader GetAttribute() IsStartElement() MoveToElement() MoveToFirstElement() MoveToNextAttribute() Read() Skip() GetAttribute() IsStartElement() MoveToElement() MoveToFirstElement() MoveToNextAttribute() Read() Skip()

XmlTextReader XmlReader is an abstract class You will use XmlTextReader, which inherits from XmlReader, and implements its methods Used with text streams XmlReader is an abstract class You will use XmlTextReader, which inherits from XmlReader, and implements its methods Used with text streams

Demonstration Projects XmlTextReader – uses XmlTextReader to retrieve all entries AttributesElements – using XmlTextReader to retrieve selected entities XmlDocument - uses XmlDocument and XmlNode classes to retrieve node objects from a Document object XmlTextReader – uses XmlTextReader to retrieve all entries AttributesElements – using XmlTextReader to retrieve selected entities XmlDocument - uses XmlDocument and XmlNode classes to retrieve node objects from a Document object

Demonstration Projects (cont’d) DataSetFromXml – synchronizes by retrieving a DataSet object from an XmlDataDocument object XmlFromDataSet – creates an XmlDataDocument from a DataSet object SynchronizeWithXmlSchema – uses an XML schema to create a DataSet object DataSetFromXml – synchronizes by retrieving a DataSet object from an XmlDataDocument object XmlFromDataSet – creates an XmlDataDocument from a DataSet object SynchronizeWithXmlSchema – uses an XML schema to create a DataSet object

The XmlNode Class Individual items in a tree representation of an XML file are called “nodes” The DOM assigns node types to different kinds of nodes In the.NET Framework, the possible node types are listed in the XmlNodeType enumeration Individual items in a tree representation of an XML file are called “nodes” The DOM assigns node types to different kinds of nodes In the.NET Framework, the possible node types are listed in the XmlNodeType enumeration

Members of The XmlNodeType Enumeration Attribute Comment Document DocumentFragment Element EndElement EndEntity Attribute Comment Document DocumentFragment Element EndElement EndEntity

Members of The XmlNodeType Enumeration (cont’d) Entity EntityReference None Notation ProcessingInstruction SignificantWhitespace Text Whitespace XmlDeclaration Entity EntityReference None Notation ProcessingInstruction SignificantWhitespace Text Whitespace XmlDeclaration

The XmlNodeClass Has a rich set of properties and methods You can retrieve or set information about an entity represented by an XmlNode object You can use its methods to navigate the DOM Has a rich set of properties and methods You can retrieve or set information about an entity represented by an XmlNode object You can use its methods to navigate the DOM

Important Properties of The XmlNode Class Attributes ChildNodes FirstChild HasChildNodes InnerText InnerXml LastChild Attributes ChildNodes FirstChild HasChildNodes InnerText InnerXml LastChild

Important Properties of The XmlNode Class (cont’d) Name NextSibling NodeType OuterXml OwnerDocument ParentNode PreviousSibling Name NextSibling NodeType OuterXml OwnerDocument ParentNode PreviousSibling

Important Methods of The XmlNode Class AppendChild() CloneNode() InsertAfter() InsertBefore() PrependChild() RemoveAll() AppendChild() CloneNode() InsertAfter() InsertBefore() PrependChild() RemoveAll()

Important Methods of The XmlNode Class (cont’d) RemoveChild() ReplaceChild() SelectNodes() SelectSingleNode() WriteContentTo() WriteTo() RemoveChild() ReplaceChild() SelectNodes() SelectSingleNode() WriteContentTo() WriteTo()

Synchronizing DataSet Objects With XML The DataSet object is an ADO.NET object that represents the structure and data of a relational database The System.Xml namespace automatically synchronizes a DataSet object with an XML file The DataSet object is an ADO.NET object that represents the structure and data of a relational database The System.Xml namespace automatically synchronizes a DataSet object with an XML file

The XmlDocument Class Represents an entire XML document XmlNode objects are associated with an XmlDocument object You navigate through the DOM representation of an XML document with these two classes Represents an entire XML document XmlNode objects are associated with an XmlDocument object You navigate through the DOM representation of an XML document with these two classes

Additional Members of The XmlDataDocument Class DataSet GetElementFromRow() GetRowFromElement() Load() DataSet GetElementFromRow() GetRowFromElement() Load()

Synchronization Process You can start with –An XmlDataDocument object –A full DataSet object –A schema-only DataSet object You can start with –An XmlDataDocument object –A full DataSet object –A schema-only DataSet object