如何使用PHP从XML标记中提取“href”属性?

时间:2014-05-06 12:03:03

标签: php html xml xml-parsing getelementsbytagname

我想从<conferencereport>标签中提取href(值 3FEDA37BCEEEB8B33FDD3B9C39FBF1CC )属性。目前有两个名称可以增加。

请提供提取这些值的逻辑。

<conferencereportlist xml:base="" xlink:href="ConferenceReportList" xlink:type="simple" dir="asc" sort="ConferenceName" total="2"     results="2" startindex="0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.avistar.com/webapi/2008/namespace">
  <conferencereport xlink:type="simple" xlink:href="conferenceReports/3FEDA37BCEEEB8B33FDD3B9C39FBF1CC">
    <conferencename>Trial Meeting Room</conferencename>
    <conferenceaddress></conferenceaddress>
    <mediaprocessorhost>WIN-1A91T1BLDKV</mediaprocessorhost>
    <starttime>05/06/2014 08:28:16 AM GMT</starttime>
    <duration>250616</duration>
    <participants>2</participants>
  </conferencereport>
  <conferencereport xlink:type="simple" xlink:href="conferenceReports/3FC55B1FFC91A2AC3FD3D7A0C3CD0EB2">
    <conferencename>Trial Meeting Room</conferencename>
    <conferenceaddress></conferenceaddress>
    <mediaprocessorhost>WIN-1A91T1BLDKV</mediaprocessorhost>
    <starttime>05/06/2014 08:42:45 AM GMT</starttime>
    <duration>602453</duration>
    <participants>1</participants>
  </conferencereport>
</conferencereportlist>

1 个答案:

答案 0 :(得分:0)

您是否尝试使用DOMElement :: getAttribute =&gt; DOMELEMENT

$href = $node->getElementsByTagName('myLink')->item(0)->getAttribute('href');