library xpath
Human-friendly xpath handling
rkr/xpath
Human-friendly xpath handling
- Wednesday, March 7, 2018
- by rkr
- Repository
- 1 Watchers
- 0 Stars
- 169 Installations
- PHP
- 0 Dependents
- 0 Suggesters
- 0 Forks
- 0 Open issues
- 9 Versions
- 2 % Grown
php-xpath
Human-friendly xpath handling, (*1)
Example 1
<?php
use Kir\XML\XPath\DomXPath;
use Kir\Streams\Impl\StringStream;
$stream = new PhpStream('tests/assets/test.html', 'r');
$xp = DomXPath::createFromHtmlStream($stream);
php_sapi_name() == 'cli' || print('
<
pre>');
foreach($xp->getNodes('//div') as $node) {
echo "{$node->getValue('./@title')}\n";
foreach($node->getNodes('./a') as $subNode) {
echo "\t{$subNode->getValue('.')}\n";
}
}
Example 2
<?php
use Kir\XML\XPath\DomXPath;
use Kir\Streams\Impl\PhpStream;
$stream = new PhpStream('tests/assets/test.xml', 'r');
$xp = DomXPath::createFromXmlString($stream, ['a' => 'https://github.com/rkrx/php-xpath/products', 'b' => 'https://github.com/rkrx/php-xpath/product']);
php_sapi_name() == 'cli' || print('
<
pre>');
foreach($xp->getNodes('/a:products/b:product') as $no => $node) {
echo "{$no}\n";
echo "\t{$node->getValue('./b:name')}\n";
echo "\t{$node->getValue('./b:ref')}\n";
echo "\t{$node->getValue('./b:price')}\n";
echo "\t{$node->getValue('./b:stock')}\n";
}
dev-master
9999999-dev
Human-friendly xpath handling
Sources
Download
MIT
The Requires
The Development Requires
by
Ron
0.2.5
0.2.5.0
Human-friendly xpath handling
Sources
Download
MIT
The Requires
The Development Requires
by
Ron
0.2.4
0.2.4.0
Human-friendly xpath handling
Sources
Download
MIT
The Requires
The Development Requires
by
Ron
0.2.3
0.2.3.0
Human-friendly xpath handling
Sources
Download
MIT
The Requires
The Development Requires
by
Ron
0.2.2
0.2.2.0
Human-friendly xpath handling
Sources
Download
MIT
The Requires
The Development Requires
by
Ron
0.2.1
0.2.1.0
Human-friendly xpath handling
Sources
Download
MIT
The Requires
The Development Requires
by
Ron
0.2
0.2.0.0
Human-friendly xpath handling
Sources
Download
MIT
The Requires
The Development Requires
by
Ron
0.1.1
0.1.1.0
Human-friendly xpath handling
Sources
Download
MIT
The Requires
The Development Requires
by
Ron
0.1
0.1.0.0
Human-friendly xpath handling
Sources
Download
MIT
The Requires
The Development Requires
by
Ron