php DOMDocument() - > loadXML()无效

时间:2014-05-08 21:58:16

标签: php xml

我有这个由GPAC MP4Box自动生成的XML。

<?xml version="1.0"?>

<!-- MPD file Generated with GPAC version 0.5.1-DEV-rev5223M  on 2014-05-08T02:46:28Z-->
<MPD 
    xmlns="urn:mpeg:dash:schema:mpd:2011" minBufferTime="PT1.500000S" type="dynamic" availabilityStartTime="2014-05-07T22:02:08Z" 
    timeShiftBufferDepth="PT0H0M0.00S" profiles="urn:mpeg:dash:profile:isoff-live:2011">
    <ProgramInformation 
        moreInformationURL="http://gpac.sourceforge.net">
        <Title>session.mpd generated by GPAC</Title>

    </ProgramInformation>

    <Period id="GENID_DEF" start="PT0H0M0.00S">
        <AdaptationSet segmentAlignment="true" maxWidth="352" 
                       maxHeight="288" maxFrameRate="5" par="352:288">
            <SegmentTemplate timescale="10240" media="stream$Number$.m4s" 
                             startNumber="1" duration="20480" initialization="streaminit.mp4"/>
            <Representation id="1" mimeType="video/mp4" 
                            codecs="avc1.42e014" width="352" height="288" frameRate="5" sar="1:1" startWithSAP="1" bandwidth="192548">
            </Representation>

        </AdaptationSet>
    </Period>
</MPD>

并且

$x = new DOMDocument();
$x->loadXML('session.mpd');

结果:

Warning: DOMDocument::loadXML(): Start tag expected, '<' not found in Entity, line: 1

有人看到了什么问题吗?

1 个答案:

答案 0 :(得分:2)

DOMDocument::loadXML期望XML源作为参数,如果要使用文件路径,请使用DOMDocument::load