Processing XML.

Slides:



Advertisements
Similar presentations
The Document Object Model (DOM) 1 JavaScript is an object-based language—that is, it’s based on manipulating objects by changing each object’s properties.
Advertisements

XML & Data Structures for the Internet Yingcai Xiao.
Chapter 13 XML Yingcai Xiao. What is XML? What is it for? Examples How to write? How to validate? How to read? How to display? How to format? How to translate?
Mark Graves Leveraging Existing DBMS Storage for XML DBMS.
 2008 Pearson Education, Inc. All rights reserved Document Object Model (DOM): Objects and Collections.
PHP with XML Dequan Chen and Narith Kun ---Term Project--- for WSU 2010 Summer Course - CS366 s:
XML files (with LINQ). Introduction to LINQ ( Language Integrated Query ) C#’s new LINQ capabilities allow you to write query expressions that retrieve.
XML C#.NET Software Development. eXtensible Markup Language Markup language that describes data Markup language that describes data Stores data as text.
HTML DOM.  The HTML DOM defines a standard way for accessing and manipulating HTML documents.  The DOM presents an HTML document as a tree- structure.
Representing Web Data: XML CSI 3140 WWW Structures, Techniques and Standards.
XP New Perspectives on XML, 2 nd Edition Tutorial 10 1 WORKING WITH THE DOCUMENT OBJECT MODEL TUTORIAL 10.
Test Automation For Web-Based Applications Portnov Computer School Presenter: Ellie Skobel.
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.
Using Visual Basic ® With The MSXML Parser Ken Spencer Vice President 32X Corporation
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.
XML DOM Functionality in.NET DSK Chakravarthy
JavaScript, Fourth Edition
1 Dr Alexiei Dingli XML Technologies XML Advanced.
WORKING WITH XML IN THE.NET FRAMEWORK. Accessing an XML File Basic activities: open it, read it.NET Framework provides structured and unstructured mechanisms.
XML Document Object Model Anthony Borquez. The Document Object Model a programming interface for HTML and XML documents. It defines the way a document.
1 Tutorial 14 Validating Documents with Schemas Exploring the XML Schema Vocabulary.
Tutorial 13 Validating Documents with Schemas
C# and Windows Programming XML Processing. 2 Contents Markup XML DTDs XML Parsers DOM.
XML Refresher Course Bálint Joó School of Physics University of Edinburgh May 02, 2003.
1 Dr Alexiei Dingli XML Technologies SAX and DOM.
Introduction to the Document Object Model Eugenia Fernandez IUPUI.
 2008 Pearson Education, Inc. All rights reserved Document Object Model (DOM): Objects and Collections.
Unit 3 — Advanced Internet Technologies Lesson 11 — Introduction to XSL.
 defined as Extensible Markup Language (XML) is a set of rules for encoding documents  Defines structure and data.
XML DOM.
XML and Object Serialization. Structure of an XML Document Header Root Element Start Tags / End Tags Element Contents – Child Elements – Text – Both (mixed.
CO1552 – Web Application Development Further JavaScript: Part 1: The Document Object Model Part 2: Functions and Events.
DOM (Document Object Model) - Parsing and Reading HTML and XML -
Lecture 23 XQuery 1.0 and XPath 2.0 Data Model. 2 Example 31.7 – User-Defined Function Function to return staff at a given branch. DEFINE FUNCTION staffAtBranch($bNo)
Working with Elements and Attributes Using DOM Eugenia Fernandez IUPUI.
Document Object Model.  The XML DOM (Document Object Model) defines a standard way for accessing and manipulating XML documents.  The DOM presents an.
Create Element, Remove Child. The Document Tree Document Element Root Element Element Element Element Element Text: HelloWorld Attribute “href”
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Representing Web Data:
USING ANDROID WITH THE DOM. Slide 2 Lecture Summary DOM concepts SAX vs DOM parsers Parsing HTTP results The Android DOM implementation.
XML DOM Week 11 Web site:
XML & JSON. Background XML and JSON are to standard, textual data formats for representing arbitrary data – XML stands for “eXtensible Markup Language”
XML. Contents  Parsing an XML Document  Validating XML Documents.
THE DOM.
XML Parsers Overview Types of parsers Using XML parsers SAX DOM
XML for .NET Session 1 Introduction to XML Introduction to XSLT
Unit 4 Representing Web Data: XML
Displaying XML Data with XSLT
Scripting the DOM MIS 3502, Fall 2016 Jeremy Shafer Department of MIS
CGS 3066: Web Programming and Design Spring 2017
WORKING WITH NAMESPACES
Applied Online Programming
CS 371 Web Application Programming
Introduction to the Document Object Model
DOM Robin Burke ECT 360.
CGS 3066: Web Programming and Design Spring 2016
Document Object Model (DOM): Objects and Collections
Chapter 7 Representing Web Data: XML
Week 11 Web site: XML DOM Week 11 Web site:
Diagramming the Tree Structure of an XML Document
XML Parsers Overview Types of parsers Using XML parsers SAX DOM
In this session, you will learn to:
Document Object Model (DOM): Objects and Collections
Chapter 13 XML Yingcai Xiao.
Quiz Points 1 Rules Raise your hand if you know the question
XML and its applications: 4. Processing XML using PHP
New Perspectives on XML
Presentation transcript:

Processing XML

Introduction Last week, you saw how to get XML This week you will learn how to process it Remember the DOM from IS 360. It all works the same way from .NET because the DOM is the DOM

XML Tree Review From W3Schools.com

XML Tree Review

XML Tree Review XML documents have exactly one root element Any element can have many child elements Nodes have a type Element / attribute / text Text is stored as a child of element Attributes are a child of element

XmlDocument Class The XmlDocument class is the belongs to the System.Xml namespace. Use it to load, validate, and edit XML documents We will just read them here There are other ways to read directly from a stream Load(stream)

XmlDocument Class: Steps to Read a Document Call the constructor to create the class instance Call LoadXml() with one argument, the string containing the document You get in-memory representation of the XML document

XmlDocument Class: Reading a Document Assume that xmlString contains an XML document System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument(); xmlDoc.LoadXml(xmlString);

Processing Documents We can extract data in different ways GetElementsByTagName() returns an XmlNodeList This is another collection So there is a Count property and an indexer GetElementById() gets an XmlNode

GetElementsByTagName() Example GetElementsByTagName takes one argument: the name of the tag and returns an XmlNodeList XmlNodeList nl; nl = xmlDoc.GetElementsByTagName("table");

The XmlNode Object It represents a node in the document A node has a type (NodeType)

The XmlNode object A node may have children (ChildNodes) A node may have content (InnerText) A node may have child XML (InnerXml) A node has a NodeType A node may have attributes (HasAttributes) If a node as attributes, then the (Attributes) collection is populated

Example, Add contents to a combo box Enumerate nodes foreach (XmlNode n in nl) { cboTables.Items.Add(n.ChildNodes[0].InnerText); }