<?php
$XMLResult = '
<root>
<a href="https://google.com/">google.com</a>
<a href="https://bing.com/">bing.com</a>
<a href="https://yahoo.com/">yahoo.com</a>
</root>';
$XML = simplexml_load_string($XMLResult);
$XMLResults = $XML->xpath('/root/a/@href');
foreach($XMLResults as $SimpleXMLElement) {
var_dump(strval($SimpleXMLElement['href']));
}
string 'https://google.com/' (length=19)
string 'https://bing.com/' (length=17)
string 'https://yahoo.com/' (length=18)
{
"cities": [
{ "name": "London", "population": 8615246 },
{ "name": "Berlin", "population": 3517424 },
{ "name": "Madrid", "population": 3165235 },
{ "name": "Rome", "population": 2870528 }
]
}
$.cities[?(@.population == 8615246)] }
[
{
"name": "London",
"population": 8615246
}
]
<root>
<a href="#"><img src="image1.jpg" /></a>
<a href="#"> <img src="image2.jpg" /> </a>
<a href="#">
<img src="image3.jpg" />
</a>
<a href="#">
<img src="image4.jpg" />
<img src="image5.jpg" />
</a>
<a href="#">
<img src="image6.jpg" />
Изображение с изображением изображения
</a>
<a href="#"><img src="image7.jpg" />Изображение с изображением изображения</a>
</root>
/root/a[normalize-space(translate(., ' ', '')) = '' and count(*) = 1]/img
Element='<img src="image1.jpg"/>'
Element='<img src="image2.jpg"/>'
Element='<img src="image3.jpg"/>'
//div[not(contains(@style, 'none'))]
div[@class='element most_wanted']//div[@class='info']/p[@class='name']/a[@class='js-serp-metrika']/@data-url
string(div[@class='element most_wanted']//div[@class='info']/p[@class='name']/a[@class='js-serp-metrika']/@data-url)
//select[@name = 'LAMP[]']/option[@value = 'yellow']
<cart>
<dimensions>15.2/44/13.5</dimensions>
</cart>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/cart">
<div>
<xsl:text>Ширина: </xsl:text>
<xsl:value-of select="substring-before(dimensions, '/')"/>
</div>
<div>
<xsl:text>Высота:</xsl:text>
<xsl:value-of select="substring-before(substring-after(dimensions, '/'), '/')"/>
</div>
<div>
<xsl:text>Глубина:</xsl:text>
<xsl:value-of select="substring-after(substring-after(dimensions, '/'), '/')"/>
</div>
</xsl:template>
</xsl:stylesheet>
<div>Ширина: 15.2</div>
<div>Высота:44</div>
<div>Глубина:13.5</div>
<root>
<foo>
<bar>
<baz>asdf</baz>
<text>text1</text>
</bar>
</foo>
<foo>
<bar>
<text>text2</text>
</bar>
</foo>
<foo>
<bar>
<baz>3</baz>
<text>text3</text>
</bar>
</foo>
</root>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/root">
<xsl:apply-templates select="foo"/>
</xsl:template>
<xsl:template match="foo">
<h1 style="color:red;">
<xsl:attribute name="style">
<xsl:choose>
<xsl:when test="count(bar/baz) > 0">
<xsl:text>color: red;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>color: green;</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:apply-templates select="bar/text"/>
</h1>
</xsl:template>
</xsl:stylesheet>
<h1 style="color: red;">text1</h1>
<h1 style="color: green;">text2</h1>
<h1 style="color: red;">text3</h1>
//div[@id = 'preloader' and not(@style)]
//div[@id = 'preloader' and @style = 'display: none;']
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/root/APPLICATION">
<html>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
<h1><xsl:value-of select="root/APPLICATION/@NAME"/> </h1>
<table border="1">
<tr>
<td>ID</td>
<td>Deleted</td>
<td>IsLocked</td>
<td>RetriveTime</td>
<td>ChangeTime</td>
<td>AccessTime</td>
<td>SecureStyleID</td>
<td>Name</td>
<td>DBName</td>
<td>TheComment</td>
</tr>
<xsl:apply-templates select="MTZAPP_COL/MTZAPP | OBJECTMODE_COL/OBJECTMODE"/>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="MTZAPP_COL/MTZAPP | OBJECTMODE_COL/OBJECTMODE">
<tr>
<td><xsl:value-of select="@ID"/></td>
<td><xsl:value-of select="@Deleted"/></td>
<td><xsl:value-of select="@IsLocked"/></td>
<td><xsl:value-of select="@RetriveTime"/></td>
<td><xsl:value-of select="@ChangeTime"/></td>
<td><xsl:value-of select="@AccessTime"/></td>
<td><xsl:value-of select="@SecureStyleID"/></td>
<td><xsl:value-of select="@Name"/></td>
<td><xsl:value-of select="@DBName"/></td>
<td><xsl:value-of select="@TheComment"/></td>
</tr>
</xsl:template>
</xsl:stylesheet>
<div>
<div class="asdf wrapper">
<table>
<tr class="table__row">
<td>
<span class="campaign-info-number">302177</span>
</td>
</tr>
<tr class="table__row">
<td>
<span class="campaign-info-number">302178</span>
</td>
</tr>
<tr class="table__row">
<td>
asdf
</td>
</tr>
</table>
</div>
</div>
//div[contains(@class, 'wrapper')]//tr[contains(@class, 'table__row') and .//span[contains(@class, 'campaign-info-number')]/text() = '302177']
<tr class="table__row">
<td>
<span class="campaign-info-number">302177</span>
</td>
</tr>
//div[@class = 'item-card-detailed__table_column item-card-detailed__table_column-second']/div[position() = count(//div[@class = 'item-card-detailed__table_column']/div[text() = 'Цвет']/preceding-sibling::div)+1]