XPathAPI 2005. 01. 05. XPathAPI HOME : API : j/apidocs/ Lib.

Slides:



Advertisements
Similar presentations
1 eXtensible Markup Language. XML is based on SGML: Standard Generalized Markup Language HTML and XML are both based on SGML 2 SGML HTMLXML.
Advertisements

XML Configuration in Java David Roossien CS62112/2009.
Continuation of chapter 6…. Nested while loop A while loop used within another while loop is called nested while loop. Q. An illustration to generate.
Api web 2.0. Representational state transfer REST is not a protocol or a format its a kind of architecture A service is accessed with its URI through.
J0 1 Marco Ronchetti - Web architectures – Laurea Specialistica in Informatica – Università di Trento Java XML parsing.
J0 1 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento.
The Java Platform and XML Portable Code, Portable Data James Duncan Davidson Staff Engineer, Sun Microsystems, Inc.
Taking Input Java Md. Eftakhairul Islam
SRW/U for DSpace Ralph LeVan Research Scientist. What is SRW/U A Pair of HTTP-based Text Query Protocols – SRW: Search and Retrieve Web Service – SRU:
Lecture 4 More on Java® Data Types, Control Structures.
4 Copyright © 2005, Oracle. All rights reserved. Creating the Web Tier: Servlets.
An introduction to Java Servlet
JSP and Servelets.
Technische universität dortmund Service Computing Service Computing Prof. Dr. Ramin Yahyapour IT & Medien Centrum 22. Oktober 2009.
Technische universität dortmund Service Computing Service Computing Prof. Dr. Ramin Yahyapour IT & Medien Centrum 24. November 2009.
Input review If review Common Errors in Selection Statement Logical Operators switch Statements Generating Random Numbers practice.
1 public class Newton { public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t)
Introduction to Computer Science Robert Sedgewick and Kevin Wayne Recursive Factorial Demo pubic class Factorial {
XML e X tensible M arkup L anguage (XML) By: Subhadeep Samantaray.
PRESENTED BY SASANKA SEKHAR BANERJEE. During this presentation, we will discuss the following: Need for XML Brief overview of XML Different methods of.
XML, Uploading, Importing... Joshua Scotton.
SE 5145 – eXtensible Markup Language (XML ) DOM (Document Object Model) (Part II – Java API) /Spring, Bahçeşehir University, Istanbul.
© 2011 Pearson Education, publishing as Addison-Wesley Chapter 3: Program Statements 3.6 – Iterators – p
Schema validation with java xml xsd Agenda Umgebung Programm Output.
 2002 Prentice Hall. All rights reserved. Chapter 9: Servlets Outline 9.1 Introduction 9.2 Servlet Overview and Architecture Interface Servlet and.
 能夠利用 XPATH 與 Xalan 套件,撰寫 JAVA 程 式,進行 XML 文件的查詢功能.
XML et JAVA SAX, DOM, xmlPull…. Plan zJAXP ySAX yDOM.
The Semantic Web. The Web Today Designed for Human to read Cannot express meaning Architecture: URL –Decentralized: Link structure Language: html.
14-Jun-15 DOM. SAX and DOM SAX and DOM are standards for XML parsers-- program APIs to read and interpret XML files DOM is a W3C standard SAX is an ad-hoc.
Xerces The Apache XML Project Yvonne Yao. Introduction Set of libraries that provides functionalities to parse XML documents Set of libraries that provides.
Apache DOM Parser©zwzOctober 24, 2002 Wenzhong Zhao Department of Computer Science The University of Kentucky.
17 Apr 2002 XML Programming: TrAX Andy Clark. Java API for XML Processing Standard Java API for loading, creating, accessing, and transforming XML documents.
Chapter 24 XML. CHAPTER GOALS Understanding XML elements and attributes Understanding the concept of an XML parser Being able to read and write XML documents.
Xpath Sources:
XML Android Club Agenda XML JSON XML eXtensible Markup Language Used for: data transfer PHP -> Java.
CSE 6331 © Leonidas Fegaras XML Tools1 XML Tools Leonidas Fegaras.
CSE 6331 © Leonidas Fegaras XML Tools1 XML Tools Leonidas Fegaras.
17 Apr 2002 XML Programming: JAXP Andy Clark. Java API for XML Processing Standard Java API for loading, creating, accessing, and transforming XML documents.
Java WWW Week 10 Version 2.1 Mar 2008 Slide Java (JSP) and XML  Format of lecture: What is XML? A sample XML file… How to use.
CSE 6331 © Leonidas Fegaras XML Tools1 XML Tools.
1 Java and XML Modified from presentation by: Barry Burd Drew University Portions © 2002 Hungry Minds, Inc.
30 May 2002 XML Apache Tools Parsing and Transformation Andy Clark.
Consuming eXtensible Markup Language (XML) feeds.
CSE 6331 © Leonidas Fegaras XML Tools1 XML Tools.
Document Object Model DOM. Agenda l Introduction to DOM l Java API for XML Parsing (JAXP) l Installation and setup l Steps for DOM parsing l Example –Representing.
Apache DOM Parser©zwzOctober 24, 2002 Wenzhong Zhao Department of Computer Science The University of Kentucky.
Schema Data Processing
1 JAXP & XPATH. Objectives 2  XPath  JAXP Processing of XPath  Workshops.
XML and Object Serialization. Structure of an XML Document Header Root Element Start Tags / End Tags Element Contents – Child Elements – Text – Both (mixed.
Java Web 应用开发: J2EE 和 Tomcat 蔡 剑, Ph.D.. 本讲内容 Web 层技术 (III) Custom Tags JSP and XML JSTL.
7-Mar-16 Simple API XML.  SAX and DOM are standards for XML parsers-- program APIs to read and interpret XML files  DOM is a W3C standard  SAX is an.
Chapter 26 XML. Chapter Goals Understanding XML elements and attributes Understanding the concept of an XML parser Being able to read and write XML documents.
USING ANDROID WITH THE DOM. Slide 2 Lecture Summary DOM concepts SAX vs DOM parsers Parsing HTTP results The Android DOM implementation.
1 Introduction SAX. Objectives 2  Simple API for XML  Parsing an XML Document  Parsing Contents  Parsing Attributes  Processing Instructions  Skipped.
21-Jun-16 Document Object Model DOM. SAX and DOM SAX and DOM are standards for XML parsers-- program APIs to read and interpret XML files DOM is a W3C.
Java API for XML Processing
Lecture Transforming Data: Using Apache Xalan to apply XSLT transformations Marc Dumontier Blueprint Initiative Samuel Lunenfeld Research Institute.
XML. Contents  Parsing an XML Document  Validating XML Documents.
{ XML Technologies } BY: DR. M’HAMED MATAOUI
Reading from a file and Writing to a file
Using XML Tools CS551 – Fall 2001.
Chapter 24 XML.
Using Jsoup to Parse HTML
Java API for XML Processing
WaysInJavaToParseXML
class PrintOnetoTen { public static void main(String args[]) {
XML document processing in Java using XPath and XSLT
XML Programming in Java
WaysInJavaToParseXML
Presentation transcript:

XPathAPI

XPathAPI HOME : API : j/apidocs/ Lib. Name : xalan.jar

XPathAPI XML

XPathAPI 1 import java.io.IOException; import org.apache.xpath.XPathAPI; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.TransformerException; import org.w3c.dom.Document; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; public class XPathTest1 { private static final String URL = " private static final String XPATH = "//item/title/text()| //item/link/text()"; public static void main(String[] args) throws SAXException, IOException, ParserConfigurationException, TransformerException { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); Document feed = factory.newDocumentBuilder().parse(URL); NodeList titles = XPathAPI.selectNodeList(feed, XPATH); System.out.println(" \r\n"); for (int i = 0; i < titles.getLength(); i+=2) { System.out.println("\t "+titles.item(i).getNodeValue()+ " \r\n"); System.out.println("\t "+titles.item(i+1).getNodeValue()+ " \r\n"); } System.out.println(" \r\n"); }

XPathAPI 2 import java.io.IOException; import org.apache.xpath.XPathAPI; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.TransformerException; import org.w3c.dom.Document; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; public class XPathTest1 { private static final String URL = " private static final String XPATH = "//item/title/text()"; public static void main(String[] args) throws SAXException, IOException, ParserConfigurationException, TransformerException { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); Document feed = factory.newDocumentBuilder().parse(URL); NodeList titles = XPathAPI.selectNodeList(feed, XPATH); System.out.println(" \r\n"); for (int i = 0; i < titles.getLength(); i++) { System.out.println("\t "+titles.item(i).getNodeValue()+ " \r\n"); } System.out.println(" \r\n"); }

XPathAPI 3 public class XPathTest1 { private static final String URL = " private static final String XPATH1 = "//item"; private static final String XPATH2 = "child::title/text()| child::link/text()"; //private static final String XPATH2 = "child::title| child::link"; public static void main(String[] args) throws SAXException, IOException, ParserConfigurationException, TransformerException { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); Document feed = factory.newDocumentBuilder().parse(URL); NodeList items = XPathAPI.selectNodeList(feed, XPATH1); System.out.println(" \r"); System.out.println(" "); for (int i = 0; i < items.getLength(); i++) { NodeList titles = XPathAPI.selectNodeList(items.item(i), XPATH2); System.out.println("\t "); for ( int j = 0 ; j < titles.getLength() ; j += 2 ) { System.out.println("\t\t "+titles.item(j).getNodeValue()+ " "); System.out.println("\t\t "+titles.item(j+1).getNodeValue()+ " "); /* System.out.println("\t\t "+titles.item(j).getTextContent()+ " "); System.out.println("\t\t "+titles.item(j+1).getTextContent()+ " "); */ } System.out.println("\t "); } System.out.println(" "); }

XPathAPI ^ ^ 1 ? [19 ] CF