Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php SimpleXMLElement在输入XML时不提供整个对象?_Php_Xml_Simplexml_Xsl Fo - Fatal编程技术网

Php SimpleXMLElement在输入XML时不提供整个对象?

Php SimpleXMLElement在输入XML时不提供整个对象?,php,xml,simplexml,xsl-fo,Php,Xml,Simplexml,Xsl Fo,我很难理解为什么当我将此XML转换为SimpleXMLElement以与XPath一起使用时,我只得到如下所示的对象。我从头到尾都验证了XML,一切都很好。那么,有什么好处呢?提前谢谢 $xml = new DOMDocument; $xml->load($xml_output); $xsl = new DOMDocument; $xsl->load($xslt_template); $proc = new XSLTProcessor; $proc->importStyleSh

我很难理解为什么当我将此XML转换为SimpleXMLElement以与XPath一起使用时,我只得到如下所示的对象。我从头到尾都验证了XML,一切都很好。那么,有什么好处呢?提前谢谢

$xml = new DOMDocument;
$xml->load($xml_output);
$xsl = new DOMDocument;
$xsl->load($xslt_template);
$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl); // attach the xsl rules

$fo_formatted = $proc->transformToXML($xml);
print_r($fo_formatted); // Results in:

  <?xml version="1.0" encoding="utf-8"?> <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xf="http://www.ecrion.com/xf/1.0" xmlns:xc="http://www.ecrion.com/2008/xc" xmlns:xfd="http://www.ecrion.com/xfd/1.0" xmlns:svg="http://www.w3.org/2000/svg" xmlns:msxsl="urn:schemas-microsoft-com:xslt" font-family="Times" font-size="12pt"> <fo:layout-master-set><fo:simple-page-master master-name="Letter Page" page-width="8.500in" page-height="11.000in"><fo:region-body region-name="xsl-region-body" margin="0.700in"/><fo:region-before region-name="xsl-region-before" display-align="after" extent="0.700in"/><fo:region-after region-name="xsl-region-after" display-align="before" extent="0.700in"/><fo:region-start region-name="xsl-region-start" extent="0.700in"/> <fo:region-end region-name="xsl-region-end" extent="0.700in"/> </fo:simple-page-master></fo:layout-master-set> <fo:page-sequence master-reference="Letter Page"> <fo:static-content flow-name="xsl-region-after"><fo:block>  </fo:block></fo:static-content><fo:static-content flow-name="xsl-region-before"><fo:block> <fo:inline>Rob</fo:inline> <fo:inline>Shafar</fo:inline>< /fo:block></fo:static-content><fo:static-content flow-name="xsl-region-end"> <fo:block> </fo:block></fo:static-content> <fo:static-content flow-name="xsl-region-start"><fo:block>  </fo:block></fo:static-content><fo:flow flow-name="xsl-region-body"> <fo:block> </fo:block><fo:block/><fo:block break-before="page">  </fo:block><fo:block> </fo:block></fo:flow></fo:page-sequence></fo:root>


$fo_formatted = new SimpleXMLElement( $fo_formatted );
print_r($fo_formatted); // Results in:


SimpleXMLElement Object
(
     [@attributes] => Array
         (
             [font-family] => Times
             [font-size] => 12pt
         )

)
$xml=新文档;
$xml->load($xml\u输出);
$xsl=新文档;
$xsl->load($xslt\u模板);
$proc=新的XSLTProcessor;
$proc->importStyleSheet($xsl);//附加xsl规则
$fo_formatted=$proc->transformToXML($xml);
打印($fo_格式);//结果:
Rob Shafar
$fo_formatted=新的simplexmlement($fo_formatted);
打印($fo_格式);//结果:
SimpleXMLElement对象
(
[@attributes]=>数组
(
[font-family]=>次
[字体大小]=>12pt
)
)

不确定,但可能是因为节点包含破折号?我认为这是无效的XML。搜索谷歌发现检查,看看你是否得到任何错误。破折号似乎不是这种情况,因为它们在FO标记中使用。尝试以下方法:删除所有未使用的名称空间(xf、xc、xfd、svg和msxsl),只留下“FO”。如果这不起作用,请从URI的末尾删除名称空间(从
xmlns:fo
中删除
:fo
)。我不知道,但事情会好起来的。谢谢你的建议,莲蓬头。