我创建了一个 simplexml php 文件,它将加载我想要提取的所有 xml 项目。唯一的问题是子项位于具有属性的项下。当我尝试拉子项目时,没有任何显示。我对使用 simplexml 还是比较陌生
XML
<Mediainfo version="0.7.62">
<File>
<track type="General">
<UniqueID_String>242652904449958064145306342749155800074 (0xB68D3FDDBE0F9B3E865F70325496B40A)</UniqueID_String>
<CompleteName>D:\Encoder\videos\raw\063 - 077 (Season_02)\064 - A Pirate-Loving Town Arrival at Whiskey Peak.mkv</CompleteName>
<Format>Matroska</Format>
<Format_Version>Version 1</Format_Version>
<FileSize_String>40.0 MiB</FileSize_String>
<Duration_String>24mn 6s</Duration_String>
<OverallBitRate_String>232 Kbps</OverallBitRate_String>
<Encoded_Date>UTC 2008-08-26 15:24:58</Encoded_Date>
<Encoded_Application>mkvmerge v2.2.0 ('Turn It On Again') built on Mar 4 2008 12:58:26</Encoded_Application>
<Encoded_Library_String>libebml v0.7.7 + libmatroska v0.8.1</Encoded_Library_String>
</track>
</File>
</Mediainfo>
我试图抓住
<UniqueID_String>242652904449958064145306342749155800074 (0xB68D3FDDBE0F9B3E865F70325496B40A)</UniqueID_String>
在下面
<track type="General">
PHP
$lib = simplexml_load_file("media.xml");
$xml = $lib->File;
$gen = $xml->track['General'];
$vid = $xml->track['Video'];
$aud = $xml->track['Audio'];
//General
$format = $gen->Format;
$app = $gen->Encoded_Application;
$size = $gen->FileSize_String;
$dur = $gen->Duration_String;
echo $format;
//Video
$vformat = $vid->Format;
$vbit = $vid->BitRate_Nominal_String;
$width = $vid->Width_String;
$height = $vid->Height_String;
$aspect = $vid->DisplayAspectRatio_String;
$frame = $vid->FrameRate_String;
$encode = $vid->Encoded_Library_String;
$encodes = $vid->Encoded_Library_Settings;
//Audio
$aformat = $aud->Format;
$compress = $aud->Compression_Mode_String;
$lang = $aud->Language_String;