【问题标题】:How do I extract the “href” attribute from an XML tag using PHP? [closed]如何使用 PHP 从 XML 标记中提取“href”属性? [关闭]
【发布时间】:2014-06-23 00:53:38
【问题描述】:

我想从<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>

【问题讨论】:

  • 你有没有尝试过?例如谷歌?您知道这不是 Google 搜索引擎,也不是 free-freelancer.com 网站吗?
  • 这不是本网站的运作方式。尝试一些东西,如果你遇到问题在这里问。这不是代码生成器。
  • 嗨。请尝试查看此处stackoverflow.com/about 以了解此处的工作方式,最后您将获得徽章。我敢肯定,如果您浏览互联网,您会找到答案。

标签: php html xml xml-parsing getelementsbytagname


【解决方案1】:

您是否尝试使用 DOMElement::getAttribute => DOMELEMENT

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

【讨论】:

    猜你喜欢
    • 2011-05-21
    • 1970-01-01
    • 2017-12-04
    • 2015-08-12
    • 1970-01-01
    • 2015-02-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多