本文整理汇总了PHP中SimpleXMLElement::__toString方法的典型用法代码示例。如果您正苦于以下问题:PHP SimpleXMLElement::__toString方法的具体用法?PHP SimpleXMLElement::__toString怎么用?PHP SimpleXMLElement::__toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleXMLElement
的用法示例。
在下文中一共展示了SimpleXMLElement::__toString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mapChildElements
/**
* Map the child elements of the current element, to the properties of the GpxElement object
*
* @param \SimpleXMLElement $element The element that we want to reformat as an object
* @return \GpxReader\GpxElement $gpxElement The object that we want to set the properties for
**/
protected function mapChildElements($element, GpxElement $gpxElement)
{
switch ($element->getName()) {
case 'ele':
$gpxElement->elevation = (double) $element->__toString();
break;
case 'time':
$gpxElement->timestamp = new \DateTime($element->__toString());
break;
}
}
示例2: childProdParse
/**
* Recusive function for parseProducts
*
* @param SimpleXMLElement $c The SimpleXMLElement object to parse
* @param int $depth Not used
* @param array $prod Custom associative array to store the parsed children
*/
public function childProdParse($c, $depth, $prod)
{
$name = $c->getName();
$value = $c->__toString();
if ($name == "Custom") {
$prod['cust_' . $c['id']->__toString()] = $value;
} elseif (isset($prod[$name])) {
if ($c->children()->count() || $c->attributes()) {
$value = ['v' => $value];
}
if ($c->attributes()) {
$value['_attr'] = [];
foreach ($c->attributes() as $a => $b) {
$value['_attr'][$a] = $b->__toString();
}
}
if ($c->children()->count()) {
$value['_children'] = [];
foreach ($c->children() as $cc) {
$value['_children'] = $this->childProdParse($cc, $depth + 1, $value['_children']);
}
}
if (is_array($prod[$name]) && !isset($prod[$name]['v'])) {
$prod[$name][] = $value;
} else {
$prod[$name] = [$prod[$name], $value];
}
} else {
if ($c->children()->count() || $c->attributes()) {
$prod[$name] = ['v' => $value];
} else {
// if($name == "Image"){
// $prod[$name] = [[$value]];
// }else
$prod[$name] = $value;
}
if ($c->attributes()) {
$prod[$name]['_attr'] = [];
foreach ($c->attributes() as $a => $b) {
$prod[$name]['_attr'][$a] = $b->__toString();
}
}
if ($c->children()->count()) {
$prod[$name]['_children'] = [];
foreach ($c->children() as $cc) {
$prod[$name]['_children'] = $this->childProdParse($cc, $depth + 1, $prod[$name]['_children']);
}
}
if ($name == "Image") {
$prod[$name] = [$prod[$name]];
}
}
return $prod;
}
示例3: handle
public function handle(ResponseCore $response)
{
$xml = new SimpleXMLElement($response->body);
$location = $xml->__toString();
return $location;
}