我正在搞乱Final Cut Pro X在执行导出时吐出的XML。我正在使用SimpleXML进行解析并遇到一些问题。我已经使用的是PHP网站上的例子 - http://www.php.net/manual/en/simplexml.examples-basic.php但我的XML是一个比较复杂 - 这里有一个例子:使用SimpleXML解析FCPx XML文件
<fcpxml>
<project name="Rought Cut 2" uid="A9BCAB6E-6D54-4809-834D-F764A741A71B" eventID="909C357C-BB9B-41E3-87A2-FC6AE3E940A0" location="file://localhost/Volumes/VideoMain/Final%20Cut%20Projects/Storm%20Chasing%20test/Rought%20Cut%202/">
<resources>
<format id="r1" name="FFVideoFormat1080p5994" frameDuration="1001/60000s" width="1920" height="1080"/>
<projectRef id="r2" name="Storm Chasing June 7" uid="909C357C-BB9B-41E3-87A2-FC6AE3E940A0"/>
<media id="r3" name="Start teaser" uid="Wn75vMb1R2anXdP2aQX5+g" projectRef="r2">
<sequence duration="393393/72000s" format="r4" tcStart="0s" tcFormat="NDF" audioLayout="stereo" renderFormat="FFRenderFormatProRes422Proxy">
<spine>
<clip offset="0s" name="HS700 - 00023" duration="445445/120000s" start="5630434810/60000s" format="r1" tcFormat="DF">
<video offset="5629760136/60000s" ref="r5" name="00023 - v1" duration="897897/60000s" start="5629760136/60000s">
<audio lane="-1" offset="4503808109/48000s" ref="r5" name="00023 - a1" duration="719039/48000s" start="4503808109/48000s" role="dialogue" outCh="L, R"/>
</video>
<title lane="1" offset="2252173924/24000s" ref="r6" name="Basic Title: Amateur Storm Chasing Mk2
" duration="360360/120000s" start="86486400/24000s">
<text>Amateur Storm Chasing Mk2
</text>
</title>
<keyword start="234573339/2500s" duration="897897/60000s" value="Hs700"/>
<metadata>
<md key="com.apple.proapps.studio.reel" value="TS700"/>
<md key="com.apple.proapps.studio.scene" value="89"/>
</metadata>
</clip>
<clip offset="267267/72000s" name="GH2 - 2012-06-07 20:27:30" duration="126126/72000s" start="45045/72000s" tcFormat="NDF">
<video offset="0s" ref="r7" name="2012-06-07 20:27:30 - v1" duration="1966965/72000s">
<audio lane="-1" offset="0s" ref="r7" name="2012-06-07 20:27:30 - a1" duration="1311310/48000s" role="dialogue" outCh="L, R"/>
</video>
的XML不只是简单的123,但那么想知道我怎么会解析它。这是我正在使用,但看着我的MAMP/PHP错误日志我看到我得到了很多错误 - SimpleXMLElement :: __构造():实体:第14行:分析器错误:(NOTE:此错误是无关的我发布的代码)。
这是我一直在玩弄代码:
<?php
include 'example.php';
$fcpxml = new SimpleXMLElement($xmlstr);
echo $fcpxml->project['name'];
?>
我敢肯定,这是简单的东西。例如。我看到我解析的XML文件使用双引号,而示例使用的是单引号。也许它不喜欢文件中的某些特殊字符,FCPx XML看起来相当复杂,而且我在编程方面很谦虚,但我认为它会编写一段脚本可以很有趣,该脚本会将我所有的剪辑名称,总长度,关键字和其他内容填充到格式良好的页面或文档中。