0

我无法理解为什么当我将此 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
         )

)
4

0 回答 0