我试图使用foreach解析以下数组数据。但我无法让它发挥作用。如何从数组数据中解析消息和xmlpath信息?
以下是使这个问题更具信息性的完整代码。我试图通过使用XmlValidator验证XML和XSD架构。目标是解析验证信息,以便控制验证产生的信息。
$xml = note.xml;
$schema = note.xsd;
$ds = DIRECTORY_SEPARATOR;
require_once(dirname(__FILE__).$ds.'XMLValidator.php');
$validator = new XMLValidator();
$result = $validator->validateXML($xml, $schema);
$result['time'] = date("Y-m-d H:i:s");
// Here is the print_r of the $result:
echo '<pre>'; print_r($result); echo '<pre/>';
Array
(
[success] =>
[messages] => Array
(
)
[errors] => Array
(
[0] => LibXMLError Object
(
[level] => 1
[code] => 1549
[column] => 0
[message] => failed to load external entity "/var/www/html/pdf/notexml"
[file] =>
[line] => 0
)
)
[xmlPath] => notexml
[mainSchemaPath] => notexsd
[time] => 2015-04-27 23:22:29
)
答案 0 :(得分:0)
研究PHP foreach函数。你可以这样做:
foreach($array as $arr){
$xmlpath = $arr['xmlPath'];
}