SlideShare a Scribd company logo
1 of 32
Download to read offline
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 RewriterIvan Shcheklein
 
Architecture of Native XML Database Sedna
Architecture of Native XML Database SednaArchitecture of Native XML Database Sedna
Architecture of Native XML Database Sednamaria.grineva
 
Functional programming with Java 8
Functional programming with Java 8Functional programming with Java 8
Functional programming with Java 8LivePerson
 
Java 8 Lambda Expressions & Streams
Java 8 Lambda Expressions & StreamsJava 8 Lambda Expressions & Streams
Java 8 Lambda Expressions & StreamsNewCircle Training
 
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 RepresentationIvan 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 TreesRay Toal
 
Domain Specific Languages In Scala Duse3
Domain Specific Languages In Scala Duse3Domain Specific Languages In Scala Duse3
Domain Specific Languages In Scala Duse3Peter Maas
 
Java 8 presentation
Java 8 presentationJava 8 presentation
Java 8 presentationVan 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 WebRyan 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 CodeKathy Brown
 
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
 
Lambda Expressions in Java
Lambda Expressions in JavaLambda Expressions in Java
Lambda Expressions in JavaErhan Bagdemir
 

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 PHPTobias Schlitt
 
Validating XML - Avoiding the pain
Validating XML - Avoiding the painValidating XML - Avoiding the pain
Validating XML - Avoiding the painTobias Schlitt
 
Spirit20090924poly
Spirit20090924polySpirit20090924poly
Spirit20090924polyGary Dare
 
XML and XPath with PHP
XML and XPath with PHPXML and XPath with PHP
XML and XPath with PHPTobias Schlitt
 
Neos Content Repository – Git for content
Neos Content Repository – Git for contentNeos Content Repository – Git for content
Neos Content Repository – Git for contentRobert 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 2010Cominvent AS
 
Microsoft kafka load imbalance
Microsoft   kafka load imbalanceMicrosoft   kafka load imbalance
Microsoft kafka load imbalanceNitin 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
 
Verification Automation Using IPXACT
Verification Automation Using IPXACTVerification Automation Using IPXACT
Verification Automation Using IPXACTDVClub
 
First compailer written
First compailer writtenFirst compailer written
First compailer writtenmicrowoorkers
 
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 / UCLAsean_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.pdfarkmuzikllc
 
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
 

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

Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 

Recently uploaded (20)

Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 

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