Whether or not the current node contains the compared value.
Access
public
Parameters
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
|
Required |
The value to use to determine whether it is contained within the node. |
Returns
Type |
Description |
|---|---|
|
Whether or not the current node contains the compared value. |
Examples
Comparison functions with CFSimpleXML
A fairly contrived example showing how to use the custom CFSimpleXML comparison functions.
// Create a contrived response object
$response = new stdClass();
$response->body = simplexml_load_file(dirname(dirname(__FILE__)) . '/_cache/describe_images.xml', 'CFSimpleXML');
// Test is()
$result = $response->body->imagesSet->item[0]->imageState->is('available');
var_dump($result);
$result = $response->body->imagesSet->item[0]->imageState->is('foo');
var_dump($result);
// Test contains()
$result = $response->body->imagesSet->item[0]->imageState->contains('ail');
var_dump($result);
$result = $response->body->imagesSet->item[0]->imageState->contains('foo');
var_dump($result);
// Test matches()
$result = $response->body->imagesSet->item[0]->imageState->matches('/a[a-z]*/');
var_dump($result);
$result = $response->body->imagesSet->item[0]->imageState->matches('/z[0-9]*/');
var_dump($result);
// Test starts_with()
$result = $response->body->imagesSet->item[0]->imageState->starts_with('ava');
var_dump($result);
$result = $response->body->imagesSet->item[0]->imageState->starts_with('zzz');
var_dump($result);
// Test ends_with()
$result = $response->body->imagesSet->item[0]->imageState->ends_with('ble');
var_dump($result);
$result = $response->body->imagesSet->item[0]->imageState->ends_with('qqq');
var_dump($result);
Result:
bool(true) bool(false) bool(true) bool(false) bool(true) bool(false) bool(true) bool(false) bool(true) bool(false)
Source
Method defined in utilities/simplexml.class.php | Toggle source view (4 lines) | View on GitHub

