Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/283.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 Xpath获取值_Php_Xslt_Xpath_Simplexml - Fatal编程技术网

从PHP Xpath获取值

从PHP Xpath获取值,php,xslt,xpath,simplexml,Php,Xslt,Xpath,Simplexml,我使用的是PHP,使用的是simplexml\u load\u字符串。我在获取子节点级别的值时遇到困难 $tmpObject=simplexml_load_string("video.xml"); $tmpObject=$tmpObject->xpath("//video-block"); $this->videoObject=array_merge($this->videoObject,$tmpObject); foreach($this->

我使用的是PHP,使用的是simplexml\u load\u字符串。我在获取子节点级别的值时遇到困难

   $tmpObject=simplexml_load_string("video.xml");
   $tmpObject=$tmpObject->xpath("//video-block");
   $this->videoObject=array_merge($this->videoObject,$tmpObject);


   foreach($this->videoObject as $key => $video) {
            echo "$key) Name: ".$video->name."\n";
            echo "$key) : ".$video->path."\n";

    }
如何从\video block\video data structure\video player\media检索高度和文件的值

以下是video.xml的内容:

  <system-video>
    <video-block> 
          <name>video1</name>
          <path>http://mycompany.com</path>
          <dynamic-metadata>
              <name>Navigation Level</name>
              <value>Undefined</value>
          </dynamic-metadata>
          <video-data-structure>
              <video-player>
                  <player>
                      <width>505</width>
                      <height>405</height>
                  </player>
                  <media>
                      <playlistfile/>
                      <file>playvideo.m4v</file>
                      <image>http://mycompany.com/jsmith.jpg</image>
                      <duration/>
                      <start/>
                  </media>
              </video-player>
          </video-data-structure>
      </video-block>
      <video-block>      
          <name>video2</name>
          <path>http://mycompany.com</path>
          <dynamic-metadata>
              <name>Navigation Level</name>
              <value>Undefined</value>
          </dynamic-metadata>
          <video-data-structure>
              <video-player>
                  <player>
                      <width>505</width>
                      <height>405</height>
                  </player>
                  <media>
                      <playlistfile/>
                      <file>playvideo2.m4v</file>
                      <image>http://mycompany.com/Tmatthews.jpg</image>
                      <duration/>
                      <start/>
                  </media>
              </video-player>
          </video-data-structure>
       </video-block>
  </system-video>

视频1
http://mycompany.com
导航级别
未定义
505
405
playvideo.m4v
http://mycompany.com/jsmith.jpg
视频2
http://mycompany.com
导航级别
未定义
505
405
播放视频2.m4v
http://mycompany.com/Tmatthews.jpg

要将外部video.xml文件作为需要使用的对象加载


PHP

$tmpObject=simplexml\u load\u文件(“video.xml”);
$tmpObject=$tmpObject->xpath(//视频块);
foreach($tmpObject作为$key=>$video)
{
$name=$video->name;
$path=$video->path;
$height=$video->{'video-data-structure'}->{'video-player'}->player->height;
$file=$video->{'video-data-structure'}->{'video-player'}->media->file;
回声
要将外部video.xml文件作为需要使用的对象加载


PHP

$tmpObject=simplexml\u load\u文件(“video.xml”);
$tmpObject=$tmpObject->xpath(//视频块);
foreach($tmpObject作为$key=>$video)
{
$name=$video->name;
$path=$video->path;
$height=$video->{'video-data-structure'}->{'video-player'}->player->height;
$file=$video->{'video-data-structure'}->{'video-player'}->media->file;
echo我会说你想要我会说你想要