SlideShare une entreprise Scribd logo
1  sur  32
Télécharger pour lire hors ligne
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

Contenu connexe

Tendances

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
 

Tendances (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
 

Similaire à 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
 

Similaire à 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
 

Dernier

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 

Dernier (20)

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 

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