SlideShare a Scribd company logo
XPath - A practical guide

        Arne Blankerts <arne@thephp.cc>, TobiasSchlitt <toby@php.net>

                                                  IPC 2009


                                               2009-11-17




Arne Blankerts, Tobias Schlitt (IPC 2009)   XPath - A practical guide   2009-11-17   1 / 26
Outline



 1 Welcome


 2 Introduction


 3 In details


 4 Quiz


 5 The end




Arne Blankerts, Tobias Schlitt (IPC 2009)   XPath - A practical guide   2009-11-17   2 / 26
Arne Blankerts




         Arne Blankerts <arne@thephp.cc>
         PHP since 1999 (10 years of PHP!)
         Co-Founder of thePHP.cc
         ballyhoo. werbeagentur.
         Open source addicted
                 Inventor and lead developer of fCMS site
                 system
                 Contributor and translator for the PHP manual




Arne Blankerts, Tobias Schlitt (IPC 2009)   XPath - A practical guide   2009-11-17   3 / 26
Tobias Schlitt



         Tobias Schlitt <toby@php.net>
         PHP since 2001
         Freelancing consultant
         Qualified IT Specialist
         Studying CS at TU Dortmund
         (finishing 2010)
         OSS addicted
                 PHP
                 eZ Components
                 PHPUnit




Arne Blankerts, Tobias Schlitt (IPC 2009)   XPath - A practical guide   2009-11-17   4 / 26
Outline



 1 Welcome


 2 Introduction
          Overview
          Basics

 3 In details


 4 Quiz


 5 The end



Arne Blankerts, Tobias Schlitt (IPC 2009)   XPath - A practical guide   2009-11-17   5 / 26
Overview


  XPath
  Enables you to select information parts from XML documents.

          Traverse the XML tree
          Select XML nodes
          W3C recommendation
          Version 1: November 1999
          Version 2: January 2007
          Fields of application
                  XSLT (XML Stylesheet Language Transformations)
                  Fetching XML nodes within programming languages




Arne Blankerts, Tobias Schlitt (IPC 2009)   XPath - A practical guide   2009-11-17   6 / 26
Addressing




          Every XPath expression matches a set of nodes (0..n)
          It encodes an “address” for the selected nodes
          Simple XPath expressions look similar to Unix file system addresses
          Absolute vs. relative addressing




Arne Blankerts, Tobias Schlitt (IPC 2009)   XPath - A practical guide   2009-11-17   7 / 26
Practical




 Let’s dig into the code




Arne Blankerts, Tobias Schlitt (IPC 2009)   XPath - A practical guide   2009-11-17   8 / 26
Outline


 1 Welcome


 2 Introduction


 3 In details
          Syntax
          Specialities
          Functions
          Axis
          PHP function integration

 4 Quiz


 5 The end

Arne Blankerts, Tobias Schlitt (IPC 2009)   XPath - A practical guide   2009-11-17   9 / 26
Syntax elements




                     / Level seperator
                  // Multi-level seperator
                     * Wildcard
                     @ Attribute prefix
                  @* Attribute wildcard
            [...] Filter / condition




Arne Blankerts, Tobias Schlitt (IPC 2009)   XPath - A practical guide   2009-11-17   10 / 26
Contexts




          Every expression step creates new context
          Next evaluated in context created by previous step




Arne Blankerts, Tobias Schlitt (IPC 2009)   XPath - A practical guide   2009-11-17   11 / 26
Navigation




                     / One level down
                  // Any number of levels down
                ../ One level up




Arne Blankerts, Tobias Schlitt (IPC 2009)   XPath - A practical guide   2009-11-17   12 / 26
Practical




 Let’s dig into the code




Arne Blankerts, Tobias Schlitt (IPC 2009)   XPath - A practical guide   2009-11-17   13 / 26
Indexing




  Access nodes by position: [2]
  Start index
       Indexing generally 1 based
          Some Internet Explorer versions start with 0




Arne Blankerts, Tobias Schlitt (IPC 2009)   XPath - A practical guide   2009-11-17   14 / 26
Union




  Union the node sets selected by multiple XPath expressions.




Arne Blankerts, Tobias Schlitt (IPC 2009)   XPath - A practical guide   2009-11-17   15 / 26
Practical




 Let’s dig into the code




Arne Blankerts, Tobias Schlitt (IPC 2009)   XPath - A practical guide   2009-11-17   16 / 26
Functions
 String                                                  Context
         string-join()                                           position()
         substring()                                             last()
         starts-with()                                   Aggregate
         contains()                                              count()
         string-length()                                         min() / max()
 Math                                                    Node
         round()                                                 local-name()
         floor()                                         Logic
                                                                 not()
                                                                 true()
  Function overview
  An overview on all functions can be found on
  http://www.w3.org/TR/xpath-functions/
Arne Blankerts, Tobias Schlitt (IPC 2009)   XPath - A practical guide            2009-11-17   17 / 26
Axis
  13 dimensions
  Imagine an XML document to be a 13 dimensional space...

                                    Axis                     Shortcut
                                    ancestor
                                    ancestor-or-self
                                    attribute                @
                                    child                    -
                                    descendant
                                    descendant-or-self       //
                                    following
                                    following-sibling
                                    namespace
                                    parent                   ..
                                    preceding
                                    preceding-sibling
                                    self                     .

Arne Blankerts, Tobias Schlitt (IPC 2009)     XPath - A practical guide   2009-11-17   18 / 26
Practical




 Let’s dig into the code




Arne Blankerts, Tobias Schlitt (IPC 2009)   XPath - A practical guide   2009-11-17   19 / 26
PHP function integration




          Register PHP callbacks to enhance functionality
          Possible since PHP 5.3.0
          Works with functions and static methods




Arne Blankerts, Tobias Schlitt (IPC 2009)   XPath - A practical guide   2009-11-17   20 / 26
Practical




 Let’s dig into the code




Arne Blankerts, Tobias Schlitt (IPC 2009)   XPath - A practical guide   2009-11-17   21 / 26
Outline



 1 Welcome


 2 Introduction


 3 In details


 4 Quiz


 5 The end




Arne Blankerts, Tobias Schlitt (IPC 2009)   XPath - A practical guide   2009-11-17   22 / 26
Quiz




          //node
          /root/element
          /root/element[1]
          @id
          /root//node/@name
          /root/element[@name = ’php’]/@*.
          ./some/*[@class=’tek’]/@id




Arne Blankerts, Tobias Schlitt (IPC 2009)   XPath - A practical guide   2009-11-17   23 / 26
Quiz




          //node
          /root/element
          /root/element[1]
          @id
          /root//node/@name
          /root/element[@name = ’php’]/@*.
          ./some/*[@class=’tek’]/@id




Arne Blankerts, Tobias Schlitt (IPC 2009)   XPath - A practical guide   2009-11-17   23 / 26
Quiz




          //node
          /root/element
          /root/element[1]
          @id
          /root//node/@name
          /root/element[@name = ’php’]/@*.
          ./some/*[@class=’tek’]/@id




Arne Blankerts, Tobias Schlitt (IPC 2009)   XPath - A practical guide   2009-11-17   23 / 26
Quiz




          //node
          /root/element
          /root/element[1]
          @id
          /root//node/@name
          /root/element[@name = ’php’]/@*.
          ./some/*[@class=’tek’]/@id




Arne Blankerts, Tobias Schlitt (IPC 2009)   XPath - A practical guide   2009-11-17   23 / 26
Quiz




          //node
          /root/element
          /root/element[1]
          @id
          /root//node/@name
          /root/element[@name = ’php’]/@*.
          ./some/*[@class=’tek’]/@id




Arne Blankerts, Tobias Schlitt (IPC 2009)   XPath - A practical guide   2009-11-17   23 / 26
Quiz




          //node
          /root/element
          /root/element[1]
          @id
          /root//node/@name
          /root/element[@name = ’php’]/@*.
          ./some/*[@class=’tek’]/@id




Arne Blankerts, Tobias Schlitt (IPC 2009)   XPath - A practical guide   2009-11-17   23 / 26
Quiz




          //node
          /root/element
          /root/element[1]
          @id
          /root//node/@name
          /root/element[@name = ’php’]/@*.
          ./some/*[@class=’tek’]/@id




Arne Blankerts, Tobias Schlitt (IPC 2009)   XPath - A practical guide   2009-11-17   23 / 26
Outline



 1 Welcome


 2 Introduction


 3 In details


 4 Quiz


 5 The end




Arne Blankerts, Tobias Schlitt (IPC 2009)   XPath - A practical guide   2009-11-17   24 / 26
Q/A




          Are there any questions left?
          Please give us some feedback!




Arne Blankerts, Tobias Schlitt (IPC 2009)   XPath - A practical guide   2009-11-17   25 / 26
The end




          Thanks for being here!
          We hope you enjoyed the session!
          Slides and material
                  Delivered by Software & Support
                  http://schlitt.info/opensource
                  On slideshare: http://www.slideshare.net/tobyS
          Contact us:
                  Arne Blankerts <arne@thephp.cc>
                  Tobias Schlitt <toby@php.net>
          Please rate our talk at: http://joind.in/1042
Arne Blankerts, Tobias Schlitt (IPC 2009)   XPath - A practical guide   2009-11-17   26 / 26

More Related Content

What's hot

Sedna XML Database: Query Parser & Optimizing Rewriter
Sedna XML Database: Query Parser & Optimizing RewriterSedna XML Database: Query Parser & Optimizing Rewriter
Sedna XML Database: Query Parser & Optimizing Rewriter
Ivan Shcheklein
 
Architecture of Native XML Database Sedna
Architecture of Native XML Database SednaArchitecture of Native XML Database Sedna
Architecture of Native XML Database Sedna
maria.grineva
 
Functional programming with Java 8
Functional programming with Java 8Functional programming with Java 8
Functional programming with Java 8
LivePerson
 
Java 8 Lambda Expressions & Streams
Java 8 Lambda Expressions & StreamsJava 8 Lambda Expressions & Streams
Java 8 Lambda Expressions & Streams
NewCircle Training
 
Java8
Java8Java8
Combinators, DSLs, HTML and F#
Combinators, DSLs, HTML and F#Combinators, DSLs, HTML and F#
Combinators, DSLs, HTML and F#
Robert Pickering
 
Sedna XML Database System: Internal Representation
Sedna XML Database System: Internal RepresentationSedna XML Database System: Internal Representation
Sedna XML Database System: Internal Representation
Ivan Shcheklein
 
An Annotation Framework for Statically-Typed Syntax Trees
An Annotation Framework for Statically-Typed Syntax TreesAn Annotation Framework for Statically-Typed Syntax Trees
An Annotation Framework for Statically-Typed Syntax Trees
Ray Toal
 
Domain Specific Languages In Scala Duse3
Domain Specific Languages In Scala Duse3Domain Specific Languages In Scala Duse3
Domain Specific Languages In Scala Duse3
Peter Maas
 
Java 8 presentation
Java 8 presentationJava 8 presentation
Java 8 presentation
Van Huong
 
Yacc (yet another compiler compiler)
Yacc (yet another compiler compiler)Yacc (yet another compiler compiler)
Yacc (yet another compiler compiler)
omercomail
 
The Functional Web
The Functional WebThe Functional Web
The Functional Web
Ryan Riley
 
10 Lines or Less; Interesting Things You Can Do In Java With Minimal Code
10 Lines or Less; Interesting Things You Can Do In Java With Minimal Code10 Lines or Less; Interesting Things You Can Do In Java With Minimal Code
10 Lines or Less; Interesting Things You Can Do In Java With Minimal Code
Kathy Brown
 
OOP and FP
OOP and FPOOP and FP
OOP and FP
Mario Fusco
 
BP107: Ten Lines Or Less: Interesting Things You Can Do In Java With Minimal ...
BP107: Ten Lines Or Less: Interesting Things You Can Do In Java With Minimal ...BP107: Ten Lines Or Less: Interesting Things You Can Do In Java With Minimal ...
BP107: Ten Lines Or Less: Interesting Things You Can Do In Java With Minimal ...
panagenda
 
Function in C++
Function in C++Function in C++
Function in C++
Prof Ansari
 
Lambda Expressions in Java
Lambda Expressions in JavaLambda Expressions in Java
Lambda Expressions in Java
Erhan Bagdemir
 
Lazy java
Lazy javaLazy java
Lazy java
Mario Fusco
 
LEX & YACC
LEX & YACCLEX & YACC
LEX & YACC
Mahbubur Rahman
 
Java 8 Lambda and Streams
Java 8 Lambda and StreamsJava 8 Lambda and Streams
Java 8 Lambda and Streams
Venkata Naga Ravi
 

What's hot (20)

Sedna XML Database: Query Parser & Optimizing Rewriter
Sedna XML Database: Query Parser & Optimizing RewriterSedna XML Database: Query Parser & Optimizing Rewriter
Sedna XML Database: Query Parser & Optimizing Rewriter
 
Architecture of Native XML Database Sedna
Architecture of Native XML Database SednaArchitecture of Native XML Database Sedna
Architecture of Native XML Database Sedna
 
Functional programming with Java 8
Functional programming with Java 8Functional programming with Java 8
Functional programming with Java 8
 
Java 8 Lambda Expressions & Streams
Java 8 Lambda Expressions & StreamsJava 8 Lambda Expressions & Streams
Java 8 Lambda Expressions & Streams
 
Java8
Java8Java8
Java8
 
Combinators, DSLs, HTML and F#
Combinators, DSLs, HTML and F#Combinators, DSLs, HTML and F#
Combinators, DSLs, HTML and F#
 
Sedna XML Database System: Internal Representation
Sedna XML Database System: Internal RepresentationSedna XML Database System: Internal Representation
Sedna XML Database System: Internal Representation
 
An Annotation Framework for Statically-Typed Syntax Trees
An Annotation Framework for Statically-Typed Syntax TreesAn Annotation Framework for Statically-Typed Syntax Trees
An Annotation Framework for Statically-Typed Syntax Trees
 
Domain Specific Languages In Scala Duse3
Domain Specific Languages In Scala Duse3Domain Specific Languages In Scala Duse3
Domain Specific Languages In Scala Duse3
 
Java 8 presentation
Java 8 presentationJava 8 presentation
Java 8 presentation
 
Yacc (yet another compiler compiler)
Yacc (yet another compiler compiler)Yacc (yet another compiler compiler)
Yacc (yet another compiler compiler)
 
The Functional Web
The Functional WebThe Functional Web
The Functional Web
 
10 Lines or Less; Interesting Things You Can Do In Java With Minimal Code
10 Lines or Less; Interesting Things You Can Do In Java With Minimal Code10 Lines or Less; Interesting Things You Can Do In Java With Minimal Code
10 Lines or Less; Interesting Things You Can Do In Java With Minimal Code
 
OOP and FP
OOP and FPOOP and FP
OOP and FP
 
BP107: Ten Lines Or Less: Interesting Things You Can Do In Java With Minimal ...
BP107: Ten Lines Or Less: Interesting Things You Can Do In Java With Minimal ...BP107: Ten Lines Or Less: Interesting Things You Can Do In Java With Minimal ...
BP107: Ten Lines Or Less: Interesting Things You Can Do In Java With Minimal ...
 
Function in C++
Function in C++Function in C++
Function in C++
 
Lambda Expressions in Java
Lambda Expressions in JavaLambda Expressions in Java
Lambda Expressions in Java
 
Lazy java
Lazy javaLazy java
Lazy java
 
LEX & YACC
LEX & YACCLEX & YACC
LEX & YACC
 
Java 8 Lambda and Streams
Java 8 Lambda and StreamsJava 8 Lambda and Streams
Java 8 Lambda and Streams
 

Similar to XPath - A practical guide

Professional XML with PHP
Professional XML with PHPProfessional XML with PHP
Professional XML with PHP
Tobias Schlitt
 
Validating XML - Avoiding the pain
Validating XML - Avoiding the painValidating XML - Avoiding the pain
Validating XML - Avoiding the pain
Tobias Schlitt
 
Spirit20090924poly
Spirit20090924polySpirit20090924poly
Spirit20090924poly
Gary Dare
 
XML and XPath with PHP
XML and XPath with PHPXML and XPath with PHP
XML and XPath with PHP
Tobias Schlitt
 
Neos Content Repository – Git for content
Neos Content Repository – Git for contentNeos Content Repository – Git for content
Neos Content Repository – Git for content
Robert Lemke
 
Key topics when migrating from FAST to Solr, EuroCon 2010
Key topics when migrating from FAST to Solr, EuroCon 2010Key topics when migrating from FAST to Solr, EuroCon 2010
Key topics when migrating from FAST to Solr, EuroCon 2010
Cominvent AS
 
Microsoft kafka load imbalance
Microsoft   kafka load imbalanceMicrosoft   kafka load imbalance
Microsoft kafka load imbalance
Nitin Kumar
 
Will iPython replace Bash?
Will iPython replace Bash?Will iPython replace Bash?
Will iPython replace Bash?
Babel
 
Will iPython replace bash?
Will iPython replace bash?Will iPython replace bash?
Will iPython replace bash?
Roberto Polli
 
Sockets and Socket-Buffer
Sockets and Socket-BufferSockets and Socket-Buffer
Sockets and Socket-Buffer
Sourav Punoriyar
 
Verification Automation Using IPXACT
Verification Automation Using IPXACTVerification Automation Using IPXACT
Verification Automation Using IPXACT
DVClub
 
First compailer written
First compailer writtenFirst compailer written
First compailer written
microwoorkers
 
Learning Erlang (from a Prolog dropout's perspective)
Learning Erlang (from a Prolog dropout's perspective)Learning Erlang (from a Prolog dropout's perspective)
Learning Erlang (from a Prolog dropout's perspective)
elliando dias
 
Fatah Uddin (072831056)
Fatah Uddin (072831056)Fatah Uddin (072831056)
Fatah Uddin (072831056)
mashiur
 
Riot Games Scalable Data Warehouse Lecture at UCSB / UCLA
Riot Games Scalable Data Warehouse Lecture at UCSB / UCLARiot Games Scalable Data Warehouse Lecture at UCSB / UCLA
Riot Games Scalable Data Warehouse Lecture at UCSB / UCLA
sean_seannery
 
IN JAVA BJP5 Exercise 6.19 leetSpeak LanguageType Java file pr.pdf
IN JAVA BJP5 Exercise 6.19 leetSpeak LanguageType  Java file pr.pdfIN JAVA BJP5 Exercise 6.19 leetSpeak LanguageType  Java file pr.pdf
IN JAVA BJP5 Exercise 6.19 leetSpeak LanguageType Java file pr.pdf
arkmuzikllc
 
mpmc cse ppt.pdf
mpmc cse ppt.pdfmpmc cse ppt.pdf
mpmc cse ppt.pdf
ssuser0132001
 
Linux rumpkernel - ABC2018 (AsiaBSDCon 2018)
Linux rumpkernel - ABC2018 (AsiaBSDCon 2018)Linux rumpkernel - ABC2018 (AsiaBSDCon 2018)
Linux rumpkernel - ABC2018 (AsiaBSDCon 2018)
Hajime Tazaki
 
Embedded Recipes 2017 - An easy-to-install real world embedded Linux distribu...
Embedded Recipes 2017 - An easy-to-install real world embedded Linux distribu...Embedded Recipes 2017 - An easy-to-install real world embedded Linux distribu...
Embedded Recipes 2017 - An easy-to-install real world embedded Linux distribu...
Anne Nicolas
 
Raspi32
Raspi32Raspi32

Similar to XPath - A practical guide (20)

Professional XML with PHP
Professional XML with PHPProfessional XML with PHP
Professional XML with PHP
 
Validating XML - Avoiding the pain
Validating XML - Avoiding the painValidating XML - Avoiding the pain
Validating XML - Avoiding the pain
 
Spirit20090924poly
Spirit20090924polySpirit20090924poly
Spirit20090924poly
 
XML and XPath with PHP
XML and XPath with PHPXML and XPath with PHP
XML and XPath with PHP
 
Neos Content Repository – Git for content
Neos Content Repository – Git for contentNeos Content Repository – Git for content
Neos Content Repository – Git for content
 
Key topics when migrating from FAST to Solr, EuroCon 2010
Key topics when migrating from FAST to Solr, EuroCon 2010Key topics when migrating from FAST to Solr, EuroCon 2010
Key topics when migrating from FAST to Solr, EuroCon 2010
 
Microsoft kafka load imbalance
Microsoft   kafka load imbalanceMicrosoft   kafka load imbalance
Microsoft kafka load imbalance
 
Will iPython replace Bash?
Will iPython replace Bash?Will iPython replace Bash?
Will iPython replace Bash?
 
Will iPython replace bash?
Will iPython replace bash?Will iPython replace bash?
Will iPython replace bash?
 
Sockets and Socket-Buffer
Sockets and Socket-BufferSockets and Socket-Buffer
Sockets and Socket-Buffer
 
Verification Automation Using IPXACT
Verification Automation Using IPXACTVerification Automation Using IPXACT
Verification Automation Using IPXACT
 
First compailer written
First compailer writtenFirst compailer written
First compailer written
 
Learning Erlang (from a Prolog dropout's perspective)
Learning Erlang (from a Prolog dropout's perspective)Learning Erlang (from a Prolog dropout's perspective)
Learning Erlang (from a Prolog dropout's perspective)
 
Fatah Uddin (072831056)
Fatah Uddin (072831056)Fatah Uddin (072831056)
Fatah Uddin (072831056)
 
Riot Games Scalable Data Warehouse Lecture at UCSB / UCLA
Riot Games Scalable Data Warehouse Lecture at UCSB / UCLARiot Games Scalable Data Warehouse Lecture at UCSB / UCLA
Riot Games Scalable Data Warehouse Lecture at UCSB / UCLA
 
IN JAVA BJP5 Exercise 6.19 leetSpeak LanguageType Java file pr.pdf
IN JAVA BJP5 Exercise 6.19 leetSpeak LanguageType  Java file pr.pdfIN JAVA BJP5 Exercise 6.19 leetSpeak LanguageType  Java file pr.pdf
IN JAVA BJP5 Exercise 6.19 leetSpeak LanguageType Java file pr.pdf
 
mpmc cse ppt.pdf
mpmc cse ppt.pdfmpmc cse ppt.pdf
mpmc cse ppt.pdf
 
Linux rumpkernel - ABC2018 (AsiaBSDCon 2018)
Linux rumpkernel - ABC2018 (AsiaBSDCon 2018)Linux rumpkernel - ABC2018 (AsiaBSDCon 2018)
Linux rumpkernel - ABC2018 (AsiaBSDCon 2018)
 
Embedded Recipes 2017 - An easy-to-install real world embedded Linux distribu...
Embedded Recipes 2017 - An easy-to-install real world embedded Linux distribu...Embedded Recipes 2017 - An easy-to-install real world embedded Linux distribu...
Embedded Recipes 2017 - An easy-to-install real world embedded Linux distribu...
 
Raspi32
Raspi32Raspi32
Raspi32
 

Recently uploaded

"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
Fwdays
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
Alex Pruden
 
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and BioinformaticiansBiomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Neo4j
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
AstuteBusiness
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
operationspcvita
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their MainframeDigital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Precisely
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
Zilliz
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
Javier Junquera
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
Jason Yip
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge GraphGraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
Neo4j
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
DianaGray10
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
c5vrf27qcz
 
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
saastr
 

Recently uploaded (20)

"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
 
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and BioinformaticiansBiomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
 
Artificial Intelligence and Electronic Warfare
Artificial Intelligence and Electronic WarfareArtificial Intelligence and Electronic Warfare
Artificial Intelligence and Electronic Warfare
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their MainframeDigital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge GraphGraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
 
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
 

XPath - A practical guide

  • 1. XPath - A practical guide Arne Blankerts <arne@thephp.cc>, TobiasSchlitt <toby@php.net> IPC 2009 2009-11-17 Arne Blankerts, Tobias Schlitt (IPC 2009) XPath - A practical guide 2009-11-17 1 / 26
  • 2. Outline 1 Welcome 2 Introduction 3 In details 4 Quiz 5 The end Arne Blankerts, Tobias Schlitt (IPC 2009) XPath - A practical guide 2009-11-17 2 / 26
  • 3. Arne Blankerts Arne Blankerts <arne@thephp.cc> PHP since 1999 (10 years of PHP!) Co-Founder of thePHP.cc ballyhoo. werbeagentur. Open source addicted Inventor and lead developer of fCMS site system Contributor and translator for the PHP manual Arne Blankerts, Tobias Schlitt (IPC 2009) XPath - A practical guide 2009-11-17 3 / 26
  • 4. Tobias Schlitt Tobias Schlitt <toby@php.net> PHP since 2001 Freelancing consultant Qualified IT Specialist Studying CS at TU Dortmund (finishing 2010) OSS addicted PHP eZ Components PHPUnit Arne Blankerts, Tobias Schlitt (IPC 2009) XPath - A practical guide 2009-11-17 4 / 26
  • 5. Outline 1 Welcome 2 Introduction Overview Basics 3 In details 4 Quiz 5 The end Arne Blankerts, Tobias Schlitt (IPC 2009) XPath - A practical guide 2009-11-17 5 / 26
  • 6. Overview XPath Enables you to select information parts from XML documents. Traverse the XML tree Select XML nodes W3C recommendation Version 1: November 1999 Version 2: January 2007 Fields of application XSLT (XML Stylesheet Language Transformations) Fetching XML nodes within programming languages Arne Blankerts, Tobias Schlitt (IPC 2009) XPath - A practical guide 2009-11-17 6 / 26
  • 7. Addressing Every XPath expression matches a set of nodes (0..n) It encodes an “address” for the selected nodes Simple XPath expressions look similar to Unix file system addresses Absolute vs. relative addressing Arne Blankerts, Tobias Schlitt (IPC 2009) XPath - A practical guide 2009-11-17 7 / 26
  • 8. Practical Let’s dig into the code Arne Blankerts, Tobias Schlitt (IPC 2009) XPath - A practical guide 2009-11-17 8 / 26
  • 9. Outline 1 Welcome 2 Introduction 3 In details Syntax Specialities Functions Axis PHP function integration 4 Quiz 5 The end Arne Blankerts, Tobias Schlitt (IPC 2009) XPath - A practical guide 2009-11-17 9 / 26
  • 10. Syntax elements / Level seperator // Multi-level seperator * Wildcard @ Attribute prefix @* Attribute wildcard [...] Filter / condition Arne Blankerts, Tobias Schlitt (IPC 2009) XPath - A practical guide 2009-11-17 10 / 26
  • 11. Contexts Every expression step creates new context Next evaluated in context created by previous step Arne Blankerts, Tobias Schlitt (IPC 2009) XPath - A practical guide 2009-11-17 11 / 26
  • 12. Navigation / One level down // Any number of levels down ../ One level up Arne Blankerts, Tobias Schlitt (IPC 2009) XPath - A practical guide 2009-11-17 12 / 26
  • 13. Practical Let’s dig into the code Arne Blankerts, Tobias Schlitt (IPC 2009) XPath - A practical guide 2009-11-17 13 / 26
  • 14. Indexing Access nodes by position: [2] Start index Indexing generally 1 based Some Internet Explorer versions start with 0 Arne Blankerts, Tobias Schlitt (IPC 2009) XPath - A practical guide 2009-11-17 14 / 26
  • 15. Union Union the node sets selected by multiple XPath expressions. Arne Blankerts, Tobias Schlitt (IPC 2009) XPath - A practical guide 2009-11-17 15 / 26
  • 16. Practical Let’s dig into the code Arne Blankerts, Tobias Schlitt (IPC 2009) XPath - A practical guide 2009-11-17 16 / 26
  • 17. Functions String Context string-join() position() substring() last() starts-with() Aggregate contains() count() string-length() min() / max() Math Node round() local-name() floor() Logic not() true() Function overview An overview on all functions can be found on http://www.w3.org/TR/xpath-functions/ Arne Blankerts, Tobias Schlitt (IPC 2009) XPath - A practical guide 2009-11-17 17 / 26
  • 18. Axis 13 dimensions Imagine an XML document to be a 13 dimensional space... Axis Shortcut ancestor ancestor-or-self attribute @ child - descendant descendant-or-self // following following-sibling namespace parent .. preceding preceding-sibling self . Arne Blankerts, Tobias Schlitt (IPC 2009) XPath - A practical guide 2009-11-17 18 / 26
  • 19. Practical Let’s dig into the code Arne Blankerts, Tobias Schlitt (IPC 2009) XPath - A practical guide 2009-11-17 19 / 26
  • 20. PHP function integration Register PHP callbacks to enhance functionality Possible since PHP 5.3.0 Works with functions and static methods Arne Blankerts, Tobias Schlitt (IPC 2009) XPath - A practical guide 2009-11-17 20 / 26
  • 21. Practical Let’s dig into the code Arne Blankerts, Tobias Schlitt (IPC 2009) XPath - A practical guide 2009-11-17 21 / 26
  • 22. Outline 1 Welcome 2 Introduction 3 In details 4 Quiz 5 The end Arne Blankerts, Tobias Schlitt (IPC 2009) XPath - A practical guide 2009-11-17 22 / 26
  • 23. Quiz //node /root/element /root/element[1] @id /root//node/@name /root/element[@name = ’php’]/@*. ./some/*[@class=’tek’]/@id Arne Blankerts, Tobias Schlitt (IPC 2009) XPath - A practical guide 2009-11-17 23 / 26
  • 24. Quiz //node /root/element /root/element[1] @id /root//node/@name /root/element[@name = ’php’]/@*. ./some/*[@class=’tek’]/@id Arne Blankerts, Tobias Schlitt (IPC 2009) XPath - A practical guide 2009-11-17 23 / 26
  • 25. Quiz //node /root/element /root/element[1] @id /root//node/@name /root/element[@name = ’php’]/@*. ./some/*[@class=’tek’]/@id Arne Blankerts, Tobias Schlitt (IPC 2009) XPath - A practical guide 2009-11-17 23 / 26
  • 26. Quiz //node /root/element /root/element[1] @id /root//node/@name /root/element[@name = ’php’]/@*. ./some/*[@class=’tek’]/@id Arne Blankerts, Tobias Schlitt (IPC 2009) XPath - A practical guide 2009-11-17 23 / 26
  • 27. Quiz //node /root/element /root/element[1] @id /root//node/@name /root/element[@name = ’php’]/@*. ./some/*[@class=’tek’]/@id Arne Blankerts, Tobias Schlitt (IPC 2009) XPath - A practical guide 2009-11-17 23 / 26
  • 28. Quiz //node /root/element /root/element[1] @id /root//node/@name /root/element[@name = ’php’]/@*. ./some/*[@class=’tek’]/@id Arne Blankerts, Tobias Schlitt (IPC 2009) XPath - A practical guide 2009-11-17 23 / 26
  • 29. Quiz //node /root/element /root/element[1] @id /root//node/@name /root/element[@name = ’php’]/@*. ./some/*[@class=’tek’]/@id Arne Blankerts, Tobias Schlitt (IPC 2009) XPath - A practical guide 2009-11-17 23 / 26
  • 30. Outline 1 Welcome 2 Introduction 3 In details 4 Quiz 5 The end Arne Blankerts, Tobias Schlitt (IPC 2009) XPath - A practical guide 2009-11-17 24 / 26
  • 31. Q/A Are there any questions left? Please give us some feedback! Arne Blankerts, Tobias Schlitt (IPC 2009) XPath - A practical guide 2009-11-17 25 / 26
  • 32. The end Thanks for being here! We hope you enjoyed the session! Slides and material Delivered by Software & Support http://schlitt.info/opensource On slideshare: http://www.slideshare.net/tobyS Contact us: Arne Blankerts <arne@thephp.cc> Tobias Schlitt <toby@php.net> Please rate our talk at: http://joind.in/1042 Arne Blankerts, Tobias Schlitt (IPC 2009) XPath - A practical guide 2009-11-17 26 / 26