我试图找到某位兄弟是否拥有兄弟,如果是的话,我想知道这些兄弟是什么。
这是可能的吗?
我试图找到某位兄弟是否拥有兄弟,如果是的话,我想知道这些兄弟是什么。
这是可能的吗?
为了选择兄弟姐妹,你必须使用相应的XPath轴。 这里是如何选择所有兄弟姐妹(调整 no子本身)
$siblings = $node->xpath( preceding-sibling::* | following-sibling::* );
你们都必须这样做。
我认为,使用xpath是你在这里最美好的:
<?php
$string = <<<XML
<?xml version= 1.0 ?>
<document>
<title>Forty What?</title>
<from>Joe</from>
<to>Jane</to>
<body>
I know that s the answer -- but what s the question?
</body>
</document>
XML;
function get_all_siblings(SimpleXMLElement $node)
{
return $node->xpath( preceding-sibling::* | following-sibling::* );
}
$xml = simplexml_load_string($string);
foreach (get_all_siblings($xml->to) as $e)
echo $e->getName()."
";
?>
成果:
title
from
body
$xml = new SimpleXMLElement($xmlstr);
$xmlNode = $xml->xpath( root/yourNodeName );
$nodeCount = count($xmlNode);
不知道这是否仍然对你有用
I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...
<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...
I found this script online that creates a thumbnail out of a image but the thumbnail image is created with poor quality how can I improve the quality of the image. And is there a better way to create ...
如何确认来自正确来源的数字。
Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...
I wonder there is a way to post a message to a facebook business page with cURL? thanks
I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...
How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...