diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml
new file mode 100644
index 00000000..6a450c24
--- /dev/null
+++ b/.github/workflows/examples.yml
@@ -0,0 +1,39 @@
+name: Examples
+
+on:
+ schedule:
+ # Weekly, on Monday morning.
+ - cron: "0 7 * * 1"
+ workflow_dispatch:
+ pull_request:
+ paths:
+ - 'examples/**'
+ - 'tests/QueryPath/ExampleRunner.php'
+ - 'tests/run-examples.php'
+ - '.github/workflows/examples.yml'
+
+jobs:
+ network:
+ name: Network examples
+ runs-on: ubuntu-latest
+
+ # These call third-party services, so they can fail for reasons that have
+ # nothing to do with a change here. The examples retry when an API asks them
+ # to slow down; anything that still fails is treated as a real problem.
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v6
+
+ - name: Setup PHP
+ uses: shivammathur/setup-php@v2
+ with:
+ php-version: '8.3'
+ ini-values: error_reporting=E_ALL
+ extensions: dom, simplexml, zip, curl
+
+ - name: Install Composer Dependencies
+ uses: ramsey/composer-install@v4
+
+ - name: Run the examples that call remote services
+ run: composer run test:examples:network
diff --git a/.github/workflows/unit-testing.yml b/.github/workflows/unit-testing.yml
index b92fc095..be8b87d8 100644
--- a/.github/workflows/unit-testing.yml
+++ b/.github/workflows/unit-testing.yml
@@ -22,6 +22,8 @@ jobs:
with:
php-version: ${{ matrix.php-versions }}
ini-values: error_reporting=E_ALL
+ # zip is needed by the .docx and .odt examples, which ExamplesTest runs.
+ extensions: dom, simplexml, zip
- name: Install Composer Dependencies
uses: ramsey/composer-install@v4
diff --git a/.gitignore b/.gitignore
index 32df0b84..ce1115a4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,3 +15,4 @@ vendor/
composer.lock
.phpunit.result.cache
.idea/
+.DS_Store
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 46c7f600..8e390a22 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,7 +3,15 @@ QueryPath Changelog
# Unreleased changes
--
+- Reorganise, modernise, and repair the `examples/` directory. Each example now lives in its own subdirectory with an `index.php`, and the full set is indexed in `examples/quickstart-guide.md`
+- Convert the remaining legacy examples: `simple_example.php`, `techniques.php`, `svg.php`, `rss.php`, `odt.php`, `parse_php.php`, and `sparql.php`
+- Fix examples that no longer ran: send a `User-Agent` where remote hosts now require one, resolve paths relative to the example rather than the working directory, and stop relying on the removed `qp.php` autoloader and the PHP 8 incompatible `eachLambda()`
+- Rewrite `examples/quickstart-guide.md`, which documented an autoloader and a set of Composer caveats that no longer apply
+- Remove unused example fixtures (`The_Beatles.rdf`, `testGrid.html`, `out.svg`) and generated output
+- Add `ext-dom` and `ext-simplexml` to the `composer.json` requirements, and `ext-zip` to the dev requirements
+- Add `QueryPathTests\ExamplesTest`, which runs every offline example on each supported PHP version and fails if one stops working. The examples that call third-party services are run by the new `Examples` workflow, weekly and whenever an example changes
+- Rewrite the cURL example against the PubMed E-utilities API. MusicBrainz throttles by IP address, which made the example unusable from any shared address
+- Add `composer run test:examples` (and `test:examples:network`) to run the examples locally
# 4.1.0
diff --git a/composer.json b/composer.json
index 4d4b236a..73af5c06 100644
--- a/composer.json
+++ b/composer.json
@@ -24,7 +24,9 @@
],
"require": {
"php": "^7.1 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0",
- "masterminds/html5": "^2.0"
+ "masterminds/html5": "^2.0",
+ "ext-dom": "*",
+ "ext-simplexml": "*"
},
"autoload": {
"psr-4": {
@@ -36,6 +38,7 @@
]
},
"require-dev": {
+ "ext-zip": "*",
"mockery/mockery": "^1.1",
"yoast/phpunit-polyfills": "^1.0",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
@@ -49,7 +52,10 @@
"scripts": {
"lint": "@php ./vendor/squizlabs/php_codesniffer/bin/phpcs",
"lint:fix": "@php ./vendor/squizlabs/php_codesniffer/bin/phpcbf",
- "lint:min-php": "@lint --standard=phpcompat.xml"
+ "lint:min-php": "@lint --standard=phpcompat.xml",
+ "test": "@php ./vendor/bin/phpunit",
+ "test:examples": "@php ./tests/run-examples.php --all",
+ "test:examples:network": "@php ./tests/run-examples.php --network"
},
"replace": {
"arthurkushman/query-path": "3.1.4",
diff --git a/examples/README.md b/examples/README.md
new file mode 100644
index 00000000..9aef54a2
--- /dev/null
+++ b/examples/README.md
@@ -0,0 +1,35 @@
+# QueryPath Examples
+
+Runnable examples covering the QueryPath API. Each one lives in its own directory
+with an `index.php` you can run directly:
+
+```bash
+composer install
+php examples/hello-world/index.php
+```
+
+Most of them print HTML, so they also work if you point a web server at this
+directory:
+
+```bash
+php -S localhost:8000 -t examples
+```
+
+**[Read the QuickStart guide](quickstart-guide.md)** — it introduces the library
+and indexes every example in this directory with a note on what each one covers.
+
+New to QueryPath? Start with [hello-world](hello-world/index.php).
+
+## Checking they all still work
+
+The offline examples are part of the unit test suite, so they run on every pull
+request across all supported PHP versions. To run the whole set — including the
+ones that call third-party services — by hand:
+
+```bash
+composer run test:examples # all of them
+composer run test:examples:network # only the ones that need a remote service
+```
+
+An example passes if it exits cleanly, emits no PHP diagnostic, and produces a
+reasonable amount of output.
diff --git a/examples/The_Beatles.rdf b/examples/The_Beatles.rdf
deleted file mode 100644
index e857d3eb..00000000
--- a/examples/The_Beatles.rdf
+++ /dev/null
@@ -1,567 +0,0 @@
-
-
-
-
-
-
- Iwanttoholdyourhandsample.ogg
-
-
-
-
-
-
-
-
-
-
-
- I Beatles sono stati un gruppo musicale britannico, originario di Liverpool e in attività dal 1962 al 1970. Hanno segnato un'epoca non solo nella musica ma anche nel costume, nella moda e nella moderna pop art. Considerati uno dei maggiori fenomeni della musica contemporanea, a distanza di vari decenni dal loro scioglimento ufficiale - e dopo la morte di due dei quattro componenti - i Beatles contano ancora su un vasto seguito. I loro lavori sono regolarmente commercializzati in versione digitale, ed arricchiti dal recupero di materiale inedito. Secondo la EMI, la casa discografica che tra il 1986 e il 1987 ne ha recuperato i diritti, le riedizioni dei loro dischi hanno venduto oltre un miliardo di copie. Per la rivista Rolling Stone, i Beatles rappresentano il gruppo musicale più importante ed influente del XX secolo Per il critico musicale Piero Scaruffi, i Beatles appartengono certamente alla storia del costume degli anni '60, ma i loro meriti musicali sono quantomeno dubbi . Numerosi sono i loro fan club, esistenti in ogni parte del mondo. Inoltre, l'aura - per molti versi non sempre codificabile secondo canoni comuni - che circonda lo sviluppo del loro successo a livello mediatico, e lo straordinario esito artistico raggiunto come musicisti-rock, sono tuttora oggetto di studio da parte di persone appassionate o estranee al mondo della musica.
-
-
- The Beatles
-
-
-
-
-
- The Beatles
-
-
-
-
-
-
-
-
-
-
-
- "Strawberry Fields Forever"
-
-
-
-
-
-
-
-
- The Beatles
-
-
- The Beatles
-
-
-
-
-
- group_or_band
-
-
-
-
-
-
-
-
- "A Day in the Life"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- The Beatles were a pop and rock band from Liverpool, England formed in 1960. Primarily consisting of John Lennon (rhythm guitar, vocals), Paul McCartney, George Harrison and Ringo Starr throughout their career, The Beatles are recognised for leading the mid-1960s musical "British Invasion" into the United States. Although their initial musical style was rooted in 1950s rock and roll and homegrown skiffle, the group explored genres ranging from Tin Pan Alley to psychedelic rock. Their clothes, styles, and statements made them trend-setters, while their growing social awareness saw their influence extend into the social and cultural revolutions of the 1960s. After the band broke up in 1970, all four members embarked upon solo careers. The Beatles are one of the most commercially successful and critically acclaimed bands in the history of popular music, selling over a billion records internationally. In the United Kingdom, The Beatles released more than 40 different singles, albums, and EPs that reached number one, earning more number one albums than any other group in UK chart history. This commercial success was repeated in many other countries; their record company, EMI, estimated that by 1985 they had sold over one billion records worldwide. According to the Recording Industry Association of America, The Beatles have sold more albums in the United States than any other band. In 2004, Rolling Stone magazine ranked The Beatles number one on its list of 100 Greatest Artists of All Time. According to that same magazine, The Beatles' innovative music and cultural impact helped define the 1960s, and their influence on pop culture is still evident today. In 2008, Billboard magazine released a list of top-selling Hot 100 artists to celebrate the chart's fiftieth anniversary; The Beatles reached #1 again.
-
-
-
-
-
-
-
-
-
-
-
- The Beatles
-
-
- ビートルズ
-
-
-
-
-
-
-
-
- "Help!"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Getbacksample.ogg
-
-
-
-
-
- Sample of "Help!".
-
-
- 220
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- The Beatles foi uma banda de rock de Liverpool, Inglaterra com suas raízes no final da década de 1950. A banda é reconhecida por ter liderado a invasão do rock inglês nos Estados Unidos no início dos anos 1960. O grupo foi formado por John Lennon (guitarra, baixo, teclado, gaita, percussão, efeito sonoro e vocal), Paul McCartney, George Harrison e Ringo Starr .O grupo obteve uma fama, popularidade e notoriedade até hoje inéditas para uma banda musical, e tornou-se a banda de maior sucesso e de maior influência do século XX. Os "garotos de Liverpool", como eram chamados, não tiveram apenas impacto sobre a música, mas também influenciaram as vestimentas, os cortes de cabelo e a forma de ser dos jovens daquela geração. Foi esse estrondoso sucesso que inspirou a criação do termo beatlemania. Suas roupas, estilos, e declarações os fizeram líderes da moda para a juventude, enquanto a percepção social do conjunto que crescia viu sua influência se estender na revolução social e cultural dos anos 1960. Atingiram o primeiro lugar nas paradas de sucesso no mundo inteiro com composições próprias como "She Loves You", "Something", "I Want to Hold Your Hand", "Can't Buy Me Love", "Help!", "Yesterday", "Eleanor Rigby", "Hey Jude", "All You Need Is Love", "Let It Be" e "Strawberry Fields Forever", entre outras. Considerado o grupo musical mais bem-sucedido da história, sendo os seus membros aclamados por público e crítica, com mais de um 1,5 bilhão de álbuns vendidos em todo o mundo, e com vinte canções que atingiram o primeiro lugar nas paradas apenas nos Estados Unidos da América, além de conseguirem ocupar em determinado momento os cinco primeiros lugares em meados de 1964 - números recordes até os dias atuais. Pela inventiva criatividade, originalidade e magia de suas canções, John Lennon e Paul McCartney são considerados a maior dupla de compositores da música popular em todo o mundo. Também foram os precursores da música indiana e oriental no pop/rock ocidental, sobretudo pela influência de George Harrison nas composições e instrumentos do grupo, em canções como "Within You Without You", "Norwegian Wood" e "Love You Too".Além de toda a repercussão, os Beatles fizeram todo um modo de criar música que influenciou não só sua época, mas todas as épocas seguintes: foram a primeira banda do planeta a fazer vídeos musicais de suas canções, e o álbum Sgt. Pepper's Lonely Hearts Club Band foi o primeiro do mundo a conter um encarte com fotos e letras de suas canções . Em 2003, a revista especializada em música Rolling Stone classificou Sgt. Pepper's como o melhor álbum de todos os tempos .
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- The Beatles
-
-
-
-
-
-
-
-
- Beatles day life.ogg
-
-
-
-
-
-
-
-
-
-
-
- The Beatles on vuosina 1960–1970 toiminut kaikkien aikojen menestynein musiikkiyhtye. Sen äänitteiden myynti on ylittänyt miljardin kappaleen rajan.. Yhtye on Yhdysvaltojen myydyin. . The Beatles aloitti harmonisten vokaaliosuuksien leimaamalla perinteisellä "beat-musiikilla". Vuoteen 1967 mennessä yhtye oli siirtynyt psykedeelisen rockin ja kokeellisten sovitusten kautta huomattavasti monimutkaisempaan ilmaisuun. Beatlesistä tuli populaarimusiikin keskeisimpiä suunnannäyttäjiä. Se on säilyttänyt suuren suosionsa myös vuonna 1970 tapahtuneen hajoamisensa jälkeen. Ennen The Beatlesia laulusolistit olivat hallinneet pop-musiikkia, mutta The Beatlesin läpimurron jälkeen yhtyeet ja niiden jäsenet saivat laulusolisteja vastaavan suosion yleisön keskuudessa. The Beatlesilla oli myös suuri vaikutus siihen, että muusikot alkoivat enemmän itse tehdä musiikkiaan, ja että pop-musiikkia alettiin pitää taiteen lajina. Musiikin uudistamisen kannalta merkittävimpänä levynä on pidetty albumia Sgt. Pepper's Lonely Hearts Club Band (1967). Beatlesin parhaaksi levyksi on ehdotettu tämän ohella myös Rubber Soulia, Revolveria, Abbey Roadia tai The Beatlesia (tunnetaan myös nimellä "The White Album" tai "Valkoinen tupla").
-
-
-
-
-
- The Beatles var en af de mest indflydelsesrige musikgrupper i 1960'erne. Udover at være en kommerciel kæmpesucces var gruppen også stilsættende hvad angår design, markedsføring og rent musikalsk. Gruppen var fire drenge fra Liverpool, der både var venner, men også konkurrenter, der bestandigt forsøgte at overgå hinanden. Kernen i gruppen var komponisterne Lennon & McCartney, der sammen og hver for sig skrev en lang stribe hitsange, som næsten alle blev indspillet af gruppen selv. Gang på gang op igennem deres karriere satte gruppen nye rekorder for, hvad der var opnåeligt indenfor populærmusikken. Gruppen blev i starten betragtet som et teenagefænomen med vildt hår og skrigende fans. Deres turnéer blev temmeligt kaotiske pga. horder af fans som blokerede lufthavne og gader, når gruppen besøgte en by. 1963 til 1966, hvor gruppen stoppede sin turnevirksomhed, var højdepunktet i Beatlemania (Beatlegalskaben), som medierne døbte fænomenet. The Beatles havde sit udgangspunkt i Mersey-beaten, med dens specielle rytme og lyd inspireret af sømændenes import af amerikanske soul-plader. Da gruppen flyttede til London for at indspille plader og derefter fik sit nationale og internationale gennembrud, blev de i høj grad eksponenter for British Invasion genren. Fra udkantsbyen Liverpool lykkedes det gruppen at erobre verden i bogstavelig forstand. Deres musik har gået sin sejrsgang verden over og influeret på, hvordan populærmusik fortolkes. Gruppen har leveret noget af den mest kopierede musik, der er skrevet. Heriblandt sangen "Yesterday", som er den mest kopierede sang nogensinde. Kategori:Kilder manglerGruppen var meget eksperimenterende i sit udtryk, men samtidig i stand til at gøre de mest rabiate nyskabelser acceptable inden for populærmusikken. Gruppen startede med rå beatmusik, for så at kombinere den hårde rock med bløde ballader, elektriske instrumenter med klassiske arrangementer, indiske instrumenter og båndklip spillet forlæns, baglæns og som tilfældigt sammenklippede lydfragmenter.
-
-
-
-
-
-
-
-
-
-
-
- The Beatles
-
-
-
-
-
- Pop, rock and various others
-
-
-
-
-
-
-
-
-
-
-
- The Beatles foi uma banda de rock de Liverpool, Inglaterra com suas raízes no final da década de 1950.
-
-
- The Beatles var et rockeband fra Liverpool som ble dannet i 1959. De debuterte på plate i 1962 med singelen «Love Me Do» som hadde moderat suksess.
-
-
-
-
-
-
-
-
- The Beatles
-
-
-
-
-
- 1960–1970, 1994–1995
-
-
-
-
-
- group_or_band
-
-
- The Beatles bootlegs
-
-
- The Beatles var en af de mest indflydelsesrige musikgrupper i 1960'erne. Udover at være en kommerciel kæmpesucces var gruppen også stilsættende hvad angår design, markedsføring og rent musikalsk.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- The Beatles were a pop and rock band from Liverpool, England formed in 1960. Primarily consisting of John Lennon (rhythm guitar, vocals), Paul McCartney, George Harrison and Ringo Starr throughout their career, The Beatles are recognised for leading the mid-1960s musical "British Invasion" into the United States. Although their initial musical style was rooted in 1950s rock and roll and homegrown skiffle, the group explored genres ranging from Tin Pan Alley to psychedelic rock. Their clothes, styles, and statements made them trend-setters, while their growing social awareness saw their influence extend into the social and cultural revolutions of the 1960s. After the band broke up in 1970, all four members embarked upon solo careers.
-
-
- The Beatles
-
-
-
-
-
-
-
-
-
-
-
- The Beatles fue un grupo musical inglés de pop rock de la década de los 60 que se formó en la ciudad de Liverpool, Inglaterra en 1957.
-
-
- I Beatles sono stati un gruppo musicale britannico, originario di Liverpool e in attivit� dal 1962 al 1970.
-
-
- The Beatles
-
-
-
-
-
- Sample of "Strawberry Fields Forever".
-
-
-
-
-
- The Beatles
-
-
-
-
-
-
-
-
- The Beatles var et rockeband fra Liverpool som ble dannet i 1959. De debuterte på plate i 1962 med singelen «Love Me Do» som hadde moderat suksess. Det store gjennombruddet i Storbritannia kom i 1963 med gruppens andre singel, «Please Please Me», som gikk til topps på de engelske hitlistene. Gjennombruddet i De forente stater kom i februar 1964, med singelen «I Want to Hold Your Hand». Gruppen forble en av de fremste populærmusikkgruppene gjennom hele 1960-tallet, frem til den ble offisielt oppløst i 1970. De hadde da dominert hitlistene og musikkbransjen på begge sider av Atlanteren gjennom hele karrieren, og er fremdeles historiens mestselgende plateartister. Kategori:Artikler som trenger referanser De påvirket etterkrigstidens babyboom-generasjon i Storbritannia, De forente stater og mange andre land i 1960-årene. De er utvilsomt den mest populære gruppen i rockehistorien, med over 1,1 milliard solgte plater verden over. Kategori:Artikler som trenger referanser Selv om de helt i begynnelsen var kjent for en variant av lett popmusikk som ble kalt merseybeat, ble deres senere verker mottatt med en popularitet og kritisk hyllest som kanskje overgår alt i det 20. århundre. De ble mer enn kun plateartister, og påvirket moter og kultur, med ringvirkninger til film og politisk aktivisme. De oppnådde en ikonstatus som ga dem enorm påvirkningskraft.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- "Get Back"
-
-
-
-
-
-
-
-
- the+beatles
-
-
- Sample of "A Day in the Life", a track appearing on Sgt. Pepper.
-
-
- Sample of "I Want to Hold Your Hand".
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- The Beatles fue un grupo musical inglés de pop rock de la década de los 60 que se formó en la ciudad de Liverpool, Inglaterra en 1957. Llamada anteriormente "The Quarrymen" y se disolvió en abril de 1970, que lideró la "Invasión británica" en los Estados Unidos.Es una de las bandas más exitosas y críticamente aclamadas de la historia de la música popular. En el Reino Unido lanzaron más de 40 diferentes singles, álbumes y EP que alcanzaron el número uno, éxito comercial que se repitió en muchos otros países. Se estima que han vendido más de mil millones de discos alrededor del mundo, según su casa de discos EMI, además de ser los artistas que más discos han vendido en la historia de los Estados Unidos, de acuerdo con la Recording Industry Association of America.Se caracterizaban en un principio por su rock and roll con raíces en los 50s, pero que con el transcurso de su carrera fueron experimentando con muchos otros géneros desde el Tin Pan Alley hasta el rock psicodélico. Su forma de vestirse, su estilo y sus declaraciones, tuvieron una inmensa influencia en la sociedad, revolucionando la cultura de la década de los 60s.En 1988, fueron los colocó en el #1 dentro de su lista de 100 Greatest Artists of All Time. De acuerdo con la misma publicación, ellos innovaron la música y su impacto cultural ayudó a definir los años 1960 y su influencia en la cultura pop aún es evidente en la actualidad, además de tener 4 álbumes entre los 10 mejores de la historia, incluyendo el 1º y el 3º. Unos años más tarde también fueron colocados en el puesto nº 1 entre Los Mejores Artistas de todos los tiempos por la página de internet de música Acclaimedmusic. net. Cite error: Invalid <ref> tag; refs with no name must have content
-
-
- The Beatles record sales, worldwide charts
-
-
-
-
-
-
-
-
- "I Want to Hold Your Hand"
-
-
- The Beatles
-
-
- The Beatles
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- The Beatles on vuosina 1960–1970 toiminut kaikkien aikojen menestynein musiikkiyhtye. Sen äänitteiden myynti on ylittänyt miljardin kappaleen rajan.. Yhtye on Yhdysvaltojen myydyin.
-
-
-
-
-
- 2008 October 2
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- The Beatles var en stilbildande brittisk pop- och rockgrupp under 1960-talet. Gruppen bestod av fyra medlemmar: John Lennon (1940-1980), Paul McCartney, George Harrison och Ringo Starr (född 1940). Samtliga medlemmar kom från Liverpool i Storbritannien. The Beatles upplöstes 1970 men är fortfarande en av världens populäraste popgrupper. Deras skivor och låtar brukar toppa omröstningar när kritiker och lyssnare röstar om världens bästa skiva eller låt.
-
-
- The Beatles waren die bekannteste englische Band der Beatmusik. Die Band formierte sich in Liverpool. Die Gruppe gilt mit bisher ca. 1,3 Milliarden verkauften Tonträgern als die erfolgreichste und einflussreichste Band des 20. Jahrhunderts. Die erste Schallplatte der Beatles erschien im Jahr 1962. Künstlerische und persönliche Differenzen führten 1970 zur Trennung der Gruppe.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- The Beatles
-
-
- The Beatles
-
-
-
-
-
- The Beatles
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Strawberryfields.ogg
-
-
-
-
-
- on
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- The Beatles
-
-
- Paul McCartney, John Lennon, George Harrison, Ringo Starr and The Beatles
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- The Beatles («Битлз»; отдельно участников ансамбля называют «битлами», также «битлзами») — британская рок-группа, внёсшая большой вклад в развитие рок-музыки. Aнсамбль не только изменил её, но и достиг беспрецедентной популярности, благодаря чему The Beatles стали одним из ярких феноменов мировой культуры 60-х гг. XX века.
-
-
- Sample of "Get Back".
-
-
- The Beatles («Битлз»; отдельно участников ансамбля называют «битлами», также «битлзами») — британская рок-группа, внёсшая большой вклад в развитие рок-музыки.
-
-
-
-
-
-
-
-
-
-
-
- List of Beatles songs
-
-
-
-
-
- 披頭四樂隊(英文:The Beatles,Beatles的意思是「甲虫」,所以又譯「甲壳虫樂隊」)来自英国利物浦的著名四人樂隊組合。他們在1962年与EMI百代唱片公司签约录制唱片。1963年初,单曲唱片《Please Please Me》登上英国排行榜首位。1964年,披头四首次前往美国演出。1966年在东京的日本武道馆举行了大规模的音乐会,1966年8月29日晚在旧金山举行最后一场收费现场音乐会。1970年4月10日,保羅·麥卡尼个人专辑中的话被媒体視為宣布樂隊解散,1970年12月31日,保罗正式起诉乐队其他三位成员,要求结束乐队合作并指明管理并分配乐队财产的正式人选。 披頭四至今已在全球售出至少7億張唱片(EMI方面宣布已超過10億張),是人類音樂史上前三暢銷的歌手。
-
-
-
-
-
- The Beatles var en stilbildande brittisk pop- och rockgrupp under 1960-talet.
-
-
- Help!.ogg
-
-
-
-
-
- 披頭四樂隊
-
-
- 披� �四樂隊(英文:The Beatles,Beatles的意思是「甲虫」,所以又譯「甲壳虫樂隊」)来自英国利物浦的著名四人樂隊組合。他們在1962年与EMI百代唱片公司签约录制唱片。1963年初,单曲唱片《Please Please Me》登上英国排行榜首位。1964年,披头四首次前往美国演出。1966年在东京的日本武道馆举行了大规模的音乐会,1966年8月29日晚在旧金山举行最后一场收费现场音乐会。1970年4月10日,保羅·麥卡尼个人专辑中的话被媒体視為宣布樂隊解散,1970年12月31日,保罗正式起诉乐队其他三位成员,要求结束乐队合作并指明管理并分配乐队财产的正式人选。 披� �四至今已在全球售出至少7億張唱片(EMI方面宣布已超過10億張),是人類音樂史上前三暢銷的歌手。
-
-
-
-
-
diff --git a/examples/at_a_glance.php b/examples/at_a_glance.php
deleted file mode 100644
index 5f95a5f2..00000000
--- a/examples/at_a_glance.php
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
one
two
three
-
-
-
four
five
six
-
-
-EOF;
-
-print "\nExample 1: \n";
-// Get all of the
elements in the document and add the
-// attribute `foo='bar'`:
-qp($xml, 'td')->attr('foo', 'bar')->writeXML();
-
-print "\nExample 2: \n";
-
-// Or print the contents of the third TD in the second row:
-print qp($xml, '#row2>td:nth(3)')->text();
-
-print "\nExample 3: \n";
-// Or append another row to the XML and then write the
-// result to standard output:
-qp($xml, 'tr:last')->after('
')->writeXML();
diff --git a/examples/test.docx b/examples/basic-docx-parser/example.docx
similarity index 100%
rename from examples/test.docx
rename to examples/basic-docx-parser/example.docx
diff --git a/examples/basic-docx-parser/example.xml b/examples/basic-docx-parser/example.xml
new file mode 100644
index 00000000..d7341169
--- /dev/null
+++ b/examples/basic-docx-parser/example.xml
@@ -0,0 +1,2035 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Computer Forensics Class Syllabus
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+ Fall
+
+
+
+
+
+
+
+
+
+ 2009
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Course No.:
+
+
+
+
+
+
+
+
+ Comp 340-001 /
+
+
+
+
+
+
+
+ Comp 488-004
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ INSTRUCTOR:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Scott Jones
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Email
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ sjone18@luc.edu
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Work Phone
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 312-915-7987
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Office Location
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 512D Lewis Tower
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Office Hours
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 6PM to 7PM Wednesdays or by appt.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ OFFICIAL TEXT:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ “Computer Evidence Collection and Preservation Second Edition”
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ by
+
+
+
+
+
+
+
+ Christopher L.T. Brown, ISBN-10: 1-58450-699-7
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ The schedule of class readings is officially as follows:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Week
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Date
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Book Chapter To Read
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ------------------------
+
+
+
+
+
+
+ -----------------------------------------------------
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 8/26
+
+
+
+
+
+
+
+
+
+
+
+
+
+ N/A – Class Intro
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 9/2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Chapters 1 & 2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 9/9
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Chapters 3 & 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 9/16
+
+
+
+
+
+
+
+ Chapters 5 & 6
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 9/23
+
+
+
+
+
+
+
+ Chapters 7 & 8
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 9/30
+
+
+
+
+
+
+
+ Chapters 9 & 10
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 10/7
+
+
+
+
+
+
+
+ Chapters 11 & 12
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 10/14
+
+
+
+
+
+
+
+ Chapters 13 & 14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 10/21
+
+
+
+
+
+
+
+ Chapters 15, 16, & 17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 10/28
+
+
+
+
+
+
+
+ In-class projects
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 11/4
+
+
+
+
+
+
+
+ In-class projects
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 11/11
+
+
+
+
+
+
+
+ In-class projects
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 11/18
+
+
+
+
+
+
+
+ In-class projects
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 11/25
+
+
+
+
+
+
+
+ In-class projects
+
+
+
+
+
+
+ *
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 12/2
+
+
+
+
+
+
+
+ In-class projects
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 12/9
+
+
+
+
+
+
+
+ In-class projects
+
+
+
+
+
+
+ *
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 12/16
+
+
+
+
+
+
+
+ In-class projects
+
+
+
+
+
+
+ *
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Class readings and assignments may change as needed.
+
+
+
+
+
+
+ 12/9/09 is generally designated a rest/study day in the academic calendar, so class may not be
+ meeting. 12/16/09 is the final Wednesday within this semester and the tentative date for the final
+ exam. This may be changed with short notice by the school as needed.
+
+
+
+
+
+
+
+ To the extent that a given date for class is cancelled by the school for any reason, that week’s reading will be bumped back accordingly.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ As newsworthy events become available, we may supplement our classroom discussions accordingly. I
+ encourage all students to pay attention to news stories on television or the Internet related to
+ computer forensics and computer technology in general.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ IN-CLASS PROJECTS:
+
+
+
+
+
+
+
+ Starting in week four, this class will begin to conduct in-class work using real-world computer
+ forensics hardware and/or software. In order to accomplish this, I highly recommend that each
+ student bring two or more USB thumb drives to class. I recommend that the smaller of the two be
+ around 512 MB in size and the larger one be at least 2 GB in size.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ QUIZZES & TESTS:
+
+
+
+
+
+
+
+ All quizzes and tests will be administered via Blackboard. Without prior arrangements I will not
+ accept make up quizzes or tests. Emergencies require that I receive an email in a timely fashion (24
+ hour period) telling me your name, the date you missed class, and explaining to me why I should
+ allow you to take the quiz or test late. By default my answer will be no. If I allow you to retake
+ the quiz or test, I reserve the right to deduct points accordingly for your lateness.
+
+
+
+
+
+
+
+ I reserve the right to give pop quizzes at any time.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ GROUPWORK:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Each student will be sharing a laptop computer with at least one other student each week. I may
+ also require students
+
+
+
+
+
+
+
+ to work in larger groups for specific tasks/projects. I reserve the right to ask specific students to swap groups if/when I find that students are not intermingling adequately. In the real world, you do not always get to choose with whom you work, and this class strives to provide real world examples and experience.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ GOALS:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ There are a few specific goals for which this class will strive.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ GOAL 1 – by mid-term, every student will have created at least one or more forensic images
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ GOAL 2 – every student understands how to create basic forensic images
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ GOAL 3 – every student understands the fundamental theories underlying computer forensics
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ GOAL 4 – every student will gain basic skills desired presently by employers for IT staff
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ GRADE SCALE:
+
+
+
+
+
+
+
+ Every student EARNS their own grade. The grading scale is as follows:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 92+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ A
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 91
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ A-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 90
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ B+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 89 – 84
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ B
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 83
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ B-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 82
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ C+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 81
+
+
+
+
+
+
+ -75
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ C
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 74
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ C-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 73
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ D+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 72-67
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ D
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 66
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ D-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 65 or less
+
+
+
+
+
+
+
+ F
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Instructor Comments:
+
+
+
+
+
+
+
+ There are no dumb questions, only unasked ones. If you do not understand something it is your
+ responsibility to let me know. Please ask questions in class, during breaks, after class, and even
+ via email if you like. I will assume you understand and m
+
+
+
+
+
+
+
+ ove on if you do not inform me otherwise
+
+
+
+
+
+
+ .
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ I welcome feedback from my students. Please feel free to send an email to the above LUC email address. No class-related emails at any other address will be accepted.
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/basic-docx-parser/index.php b/examples/basic-docx-parser/index.php
new file mode 100644
index 00000000..26cb440e
--- /dev/null
+++ b/examples/basic-docx-parser/index.php
@@ -0,0 +1,137 @@
+ a paragraph
+ * a run - a span of text sharing one set of formatting
+ * the run's formatting ( for bold, for underline)
+ * the text itself
+ *
+ * A copy of the extracted XML is included as `example.xml` if you want to read
+ * through it.
+ *
+ * @author Emily Brand
+ * @license LGPL The GNU Lesser GPL (LGPL) or an MIT-like license.
+ * @see https://www.php.net/manual/en/class.ziparchive.php
+ */
+
+use QueryPath\CSS\ParseException;
+use QueryPath\DOMQuery;
+use QueryPath\Exception;
+
+require_once __DIR__ . '/../../vendor/autoload.php';
+
+echo '
Create a Basic Docx Parser
';
+
+echo '
This example parses example.docx, walks its nodes, and displays the text with basic formatting. example.xml in this directory is the XML extracted from that file - the document QueryPath actually processes.
';
+
+echo '
Content of example.docx file...
';
+
+try {
+ // Load the example.docx file, parse for text nodes and output with basic formatting
+ foreach (qp(docx2text(__DIR__ . '/example.docx'), 'w|p') as $qp) {
+ /** @var $qp DOMQuery */
+ /** @var $qr DOMQuery */
+ foreach ($qp->find('w|r') as $qr) {
+ echo format($qr);
+ }
+
+ echo ' ';
+ }
+} catch (Exception $e) {
+ echo $e->getMessage();
+ exit(1);
+}
+
+/**
+ * Get the node text and apply basic formatting, if necessary
+ *
+ * @param DOMQuery $qp
+ *
+ * @return string
+ * @throws ParseException
+ * @throws Exception
+ */
+function format(DOMQuery $qp): string
+{
+ $text = $qp->find('w|t')->text() . ' ';
+
+ $text = checkUnderline($qp) ? sprintf('%s', $text) : $text;
+ $text = checkBold($qp) ? sprintf('%s', $text) : $text;
+
+ return $text;
+}
+
+/**
+ * Look for the node to determine if the text is bolded
+ *
+ * @param DOMQuery $qp
+ *
+ * @return bool
+ * @throws ParseException
+ * @throws Exception
+ */
+function checkBold(DOMQuery $qp): bool
+{
+ return (bool) $qp->children('w|rPr')
+ ->children('w|b')
+ ->count();
+}
+
+/**
+ * Look for the node to determine if the text is underlined
+ *
+ * @param DOMQuery $qp
+ *
+ * @return bool
+ * @throws ParseException
+ * @throws Exception
+ */
+function checkUnderline(DOMQuery $qp): bool
+{
+ return (bool) $qp->children('w|rPr')
+ ->children('w|u')
+ ->count();
+}
+
+/**
+ * Extract the text from a docx file
+ *
+ * @param string $archiveFile The path to the .docx file to extract information from
+ * @return string
+ */
+function docx2text(string $archiveFile): string
+{
+ $dataFile = 'word/document.xml';
+
+ if (!class_exists('ZipArchive', false)) {
+ throw new RuntimeException('ZipArchive extension must be enabled to parse .docx files');
+ }
+
+ $zip = new ZipArchive();
+ // Open received archive file
+ if (true !== $zip->open($archiveFile)) {
+ throw new RuntimeException('Could not open the file using ZipArchive: ' . $zip->getStatusString());
+ }
+
+ $data = '';
+ // Search for the docx data file
+ if (($index = $zip->locateName($dataFile)) !== false) {
+ $data = $zip->getFromIndex($index);
+ }
+
+ // Close zip to prevent memory leak
+ $zip->close();
+
+ return $data;
+}
diff --git a/examples/basic-manipulation-filter-and-retrieval/index.php b/examples/basic-manipulation-filter-and-retrieval/index.php
new file mode 100644
index 00000000..3a44296f
--- /dev/null
+++ b/examples/basic-manipulation-filter-and-retrieval/index.php
@@ -0,0 +1,208 @@
+ block. Use writeHTML(),
+ * writeHTML5(), or writeXML() instead when you want the document written
+ * straight to the output buffer.
+ */
+
+/*
+ * HTML Example
+ */
+$html = <<
+
+
one
+
two
+
three
+
+
+
+
four
+
five
+
six
+
+
+EOF;
+
+/*
+ * XML Example
+ */
+$xml = <<
+
+
+ This is the DOM description...
+
+
+
+ This is the Traversing description...
+
+
+
+ This is the Filtering description...
+
+
+
+ This is the Selectors description...
+
+
+EOF;
+
+try {
+ echo '
Basic HTML Usage
';
+ echo 'The following HTML chunk will get parsed, traverse, filtered, and manipulated:';
+ echo '
' . htmlspecialchars($html) . '
';
+
+ echo '
Example 1
';
+ echo 'Add the attribute class="cell" to all <td> elements:';
+
+ echo '
';
+
+ echo 'This will output the following HTML:';
+
+ echo '
';
+
+ echo htmlspecialchars(
+ html5qp($html, 'td')
+ ->attr('class', 'cell')
+ ->parents('table') // traverse up the DOM until we match the table
+ ->html() // get the HTML of the table
+ );
+
+ echo '
';
+
+ echo 'If you want to output a valid HTML document, replace parents(\'table\') with top():';
+
+ echo '
';
+ echo 'Find and output the text of the second cell in the second row of the table:';
+
+ $text = html5qp($html)
+ ->find('#row2 > td:nth-child(2)')
+ ->text();
+
+ echo '
';
+ echo 'Append an additional row at the end of the table:';
+ echo '
<?php
+
+echo html5qp($html, "td")
+->after("<tr><td>seven</td><td>eight</td><td>nine</td></tr>")
+->parents("table") // traverse up the DOM until we match the table
+->html()
+
';
+
+ echo 'This will output the following HTML:';
+
+ echo '
';
+ echo 'The following XML will get parsed, traverse, filtered, and manipulated:';
+ echo '
' . htmlspecialchars($xml) . '
';
+
+ echo '
Example 1
';
+ echo 'Add the attribute class="item" to all <desc> elements:';
+
+ echo '
<?php
+
+echo qp($xml, "desc")
+->attr("class", "item)
+->top() // return to the root node (<categories>)
+->xml(); // output a valid XML document.
+
';
+
+ echo 'This will output the following XML:';
+
+ echo '
';
+
+ echo htmlspecialchars(
+ qp($xml, 'desc')
+ ->attr('class', 'item')
+ ->top() // return to the root node
+ ->xml() // output a valid XML document
+ );
+
+ echo '
';
+
+ echo 'You can omit the XML declaration by setting the first argument to true: ->xml(true).';
+
+ echo '
Example 2
';
+ echo 'Find and output the text of the third <desc> tag:';
+
+ $text = qp($xml)
+ ->find('categories > category:nth-child(3) desc')
+ ->text();
+
+ echo '
';
+} catch (\QueryPath\Exception $e) {
+ // Handle QueryPath exceptions
+ echo $e->getMessage();
+ exit(1);
+}
diff --git a/examples/openoffice.odt b/examples/basic-odt-parser/example.odt
similarity index 100%
rename from examples/openoffice.odt
rename to examples/basic-odt-parser/example.odt
diff --git a/examples/basic-odt-parser/index.php b/examples/basic-odt-parser/index.php
new file mode 100644
index 00000000..aa78af71
--- /dev/null
+++ b/examples/basic-odt-parser/index.php
@@ -0,0 +1,98 @@
+
+ * @license LGPL The GNU Lesser GPL (LGPL) or an MIT-like license.
+ * @see https://www.php.net/manual/en/wrappers.compression.php
+ */
+
+require_once __DIR__ . '/../../vendor/autoload.php';
+
+echo '
Parsing an Open Document Text file
';
+
+echo '
This example reads example.odt and rebuilds its outline, bullet list, and ordered list.
';
+
+try {
+ /*
+ * Point QueryPath at content.xml inside the ZIP archive.
+ *
+ * The zip:// wrapper takes the form zip://#
+ */
+ $doc = qp('zip://' . __DIR__ . '/example.odt#content.xml');
+
+ /*
+ * Build the document outline.
+ *
+ * Every heading is a element, and its depth is recorded in the
+ * text:outline-level attribute. Namespaced attributes use the same pipe
+ * syntax as elements.
+ */
+ echo '
';
+
+ /*
+ * ODT does not mark up bullet and numbered lists differently - both are a
+ * . What separates them is the list style applied to it, so we
+ * match on the text:style-name attribute.
+ *
+ * Each item is a wrapping a .
+ */
+ echo '
';
+ }
+
+ echo '';
+
+ /*
+ * Body copy is stored in elements. Skipping the empty ones keeps
+ * the blank "spacer" paragraphs a word processor leaves behind out of the way.
+ */
+ echo '
';
+
+echo 'You can use QueryPath to build complex HTML documents using a simple jQuery-like API:';
+
+/*
+ * The chain below finishes with html(), which returns the markup as a string so
+ * it can be escaped and shown inside a
block. To send the document
+ * straight to the output buffer instead, swap html() for writeHTML() (or
+ * writeHTML5() / writeXML(), depending on the format you want).
+ */
+
+echo '
<?php
+
+// Begin with an HTML5 stub document and navigate to the title.
+echo html5qp(\QueryPath\QueryPath::HTML5_STUB, "title")
+ // Add text to the title
+ ->text("Example of QueryPath.")
+ // Traverse to the root of the document, then locate the body tag
+ ->top("body")
+ // Inside the body, add a heading and paragraph.
+ ->append("<h1>This is a test page</h1><p>Test text</p>")
+ // Select the paragraph we just created inside the body
+ ->children("p")
+ // Add a class attribute to the paragraph
+ ->attr("class", "some-class")
+ // And an inline style to the paragraph
+ ->css("background-color", "#eee")
+ // Traverse back up the DOM to the body
+ ->parent()
+ // Add an empty table to the body, before the heading
+ ->prepend("<table id=\'my-table\'></table>")
+ // Now go to the table...
+ ->find("#my-table")
+ // Add a couple of empty rows
+ ->append("<tr></tr><tr></tr>")
+ // select the rows (both at once)
+ ->children()
+ // Add a CSS class to both rows
+ ->addClass("table-row")
+ // Get the first row (at position 0)
+ ->eq(0)
+ // Add a table header in the first row
+ ->append("<th>This is the header</th>")
+ // Now go to the next row
+ ->next()
+ // Add some data to this row
+ ->append("<td>This is the data</td>")
+ // Traverse to the root of the document
+ ->top()
+ // Write it all out as HTML
+ ->html();
+';
+
+echo '
';
+
+echo '
Results
';
+
+try {
+ echo '
';
+
+ echo htmlspecialchars(
+ // Begin with an HTML5 stub document and navigate to the title.
+ html5qp(\QueryPath\QueryPath::HTML5_STUB, 'title')
+ // Add text to the title
+ ->text('Example of QueryPath.')
+ // Traverse to the root of the document, then locate the body tag
+ ->top('body')
+ // Inside the body, add a heading and paragraph.
+ ->append('
This is a test page
Test text
')
+ // Select the paragraph we just created inside the body
+ ->children('p')
+ // Add a class attribute to the paragraph
+ ->attr('class', 'some-class')
+ // And an inline style to the paragraph
+ ->css('background-color', '#eee')
+ // Traverse back up the DOM to the body
+ ->parent()
+ // Add an empty table to the body, before the heading
+ ->prepend('
')
+ // Now let's go to the table...
+ ->find('#my-table')
+ // Add a couple of empty rows
+ ->append('
')
+ // select the rows (both at once)
+ ->children()
+ // Add a CSS class to both rows
+ ->addClass('table-row')
+ // Get the first row (at position 0)
+ ->eq(0)
+ // Add a table header in the first row
+ ->append('
This is the header
')
+ // Now go to the next row
+ ->next()
+ // Add some data to this row
+ ->append('
This is the data
')
+ // Traverse to the root of the document
+ ->top()
+ // Write it all out as HTML
+ ->html()
+ );
+
+ echo '
';
+} catch (\QueryPath\Exception $e) {
+ echo $e->getMessage();
+ exit(1);
+}
diff --git a/examples/create-svg-document/index.php b/examples/create-svg-document/index.php
new file mode 100644
index 00000000..1c7babae
--- /dev/null
+++ b/examples/create-svg-document/index.php
@@ -0,0 +1,65 @@
+ shapes.svg
+ *
+ * @author M Butcher
+ * @license LGPL The GNU Lesser GPL (LGPL) or an MIT-like license.
+ * @see https://www.w3.org/TR/SVG11/
+ */
+
+require_once __DIR__ . '/../../vendor/autoload.php';
+
+/*
+ * A minimal SVG document to build on top of.
+ *
+ * Like every XML document handled by qp(), it begins with the XML declaration.
+ */
+$svg_stub = '
+';
+
+try {
+ qp($svg_stub)
+ // The root