PHP 解析 XML 时出错(RSS 提要)

2024-01-29

我正在使用基于的 PHP 类在这个答案中找到的 https://stackoverflow.com/questions/250679/best-way-to-parse-rss-atom-feeds-with-php解析五个 RSS 提要。五人中的四人工作没有任何问题,但是其中之一 http://ahima.org/RSS/News-Alerts-RSS.aspx给了我一些错误。是 XML 格式错误还是其他问题?我无法控制 RSS 提要的来源,但希望通知所有者是否是他们的问题。

提前致谢。

PHP 错误:

Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 35: parser error : xmlParseEntityRef: no name in _rss.php on line 59

Warning: simplexml_load_string() [function.simplexml-load-string]: ne is June 30. The award will be presented at the 84th AHIMA Annual Convention & in _rss.php on line 59

Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in _rss.php on line 59

Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 64: parser error : EntityRef: expecting ';' in _rss.php on line 59

Warning: simplexml_load_string() [function.simplexml-load-string]: e code modifications presented at the ICD-9-CM Coordination and Maintenance (C&M in _rss.php on line 59

Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in _rss.php on line 59

XML / RSS 源(在线于http://ahima.org/RSS/News-Alerts-RSS.aspx http://ahima.org/RSS/News-Alerts-RSS.aspx):

<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
    <channel>
        <generator>RSS Builder by AHIMA</generator>
        <title>News And Alerts</title>
        <link>http://www.ahima.org/</link>
        <description>News and Alerts from AHIMA.ORG</description>
        <language>en-us</language>
        <managingEditor>[email protected] /cdn-cgi/l/email-protection</managingEditor>
        <webMaster>[email protected] /cdn-cgi/l/email-protection</webMaster>
        <copyright>2010 AHIMA</copyright>
        <item>
            <title>Exclusive Coverage of AHIMA ICD-10 Summit</title>
            <pubDate>4/13/2012 2:39:54 PM</pubDate>
            <link>http://journal.ahima.org/icdsummit/</link>
            <author>web[email protected] /cdn-cgi/l/email-protection</author>
            <category>News - Alerts</category>
            <description>The summit takes place April 16–17 in Baltimore, MD, and explores the challenges and opportunities involved in the transition to the ICD-10-CM/PCS coding systems. The Journal’s coverage begins April 11 with session previews and comments from the presenters. Keep up to date on the summit by checking this site daily, subscribing to the RRS feed, and following @JournalofAHIMA on Twitter. Follow the Twitter hash tag #ICD10Summit for updates from summit attendees.</description>
        </item><item>
            <title>AHIMA: Remain Focused on Expediting ICD-10 Implementation</title>
            <pubDate>4/10/2012 2:18:22 PM</pubDate>
            <link>http://www.ahima.org/downloads/pdfs/pr/press-releases/HHS%20Announces%20IDC-10%20Delay.pdf</link>
            <author>[email protected] /cdn-cgi/l/email-protection</author>
            <category>News - Alerts</category>
            <description>CHICAGO – April 10, 2012 – In light of the U.S. Department of Health and Human Services (HHS) proposed one-year delay in implementing ICD-10-CM or ICD-10-PCS for HIPAA covered entities, AHIMA encouraged organizations to remain focused on their implementation efforts.
</description>
        </item><item>
            <title>Call for Nominations: New AHIMA Grace Award</title>
            <pubDate>3/30/2012 11:45:09 AM</pubDate>
            <link>/about/grace.aspx</link>
            <author>[email protected] /cdn-cgi/l/email-protection</author>
            <category>News - Alerts</category>
            <description>Grace Award: In Recognition of Excellence in Health Information Management will honor healthcare delivery organizations that demonstrate effective and innovative approaches in using health information to deliver quality healthcare.

Nomination applications are now available, and the submission deadline is June 30. The award will be presented at the 84th AHIMA Annual Convention & Exhibit in Chicago, September 29-October 4.</description>
        </item><item>
            <title>Practice Brief: Mobile Device Security</title>
            <pubDate>4/13/2012 2:44:19 PM</pubDate>
            <link>http://library.ahima.org/xpedio/groups/public/documents/ahima/bok1_049463.hcsp?dDocName=bok1_049463</link>
            <author>[email protected] /cdn-cgi/l/email-protection</author>
            <category>News - Alerts</category>
            <description>Mobile devices have pervaded the everyday work environment in healthcare. An organization may use mobile devices to improve clinician workflow, bedside information gathering and reporting, or a host of other care delivery applications. In some cases, individuals may use their own mobile devices to meet their personal workflow requirements. 

Whatever purpose the device serves, healthcare organizations must be prepared to understand all the issues related to mobile device use. 

This practice brief reviews the legal and regulatory requirements that affect mobile device use in healthcare. It also provides best practices for ensuring appropriate safeguards are in place to protect all electronic protected health information (ePHI) used and processed within mobile devices.</description>
        </item><item>
            <title>Workflow and EHRs in Small Medical Practices </title>
            <pubDate>4/13/2012 2:45:16 PM</pubDate>
            <link>http://perspectives.ahima.org/index.php?option=com_content&amp;view=article&amp;id=247:workflow-and-electronic-health-records-in-small-medical-practices&amp;catid=42:electronic-records&amp;Itemid=88</link>
            <author>[email protected] /cdn-cgi/l/email-protection</author>
            <category>News - Alerts</category>
            <description>This paper analyzes the workflow and implementation of electronic health record (EHR) systems across different functions in small physician offices. We characterize the differences in the offices based on the levels of computerization in terms of workflow, sources of time delay, and barriers to using EHR systems to support the entire workflow.

The study was based on a combination of questionnaires, interviews, in situ observations, and data collection efforts. This study was not intended to be a full-scale time-and-motion study with precise measurements but was intended to provide an overview of the potential sources of delays while performing office tasks. The study follows an interpretive model of case studies rather than a large-sample statistical survey of practices. To identify time-consuming tasks, workflow maps were created based on the aggregated data from the offices. The results from the study show that specialty physicians are more favorable toward adopting EHR systems than primary care physicians are. The barriers to adoption of EHR systems by primary care physicians can be attributed to the complex workflows that exist in primary care physician offices, leading to nonstandardized workflow structures and practices. Also, primary care physicians would benefit more from EHR systems if the systems could interact with external entities. 

</description>
        </item><item>
            <title>AHIMA Comments on Proposed Modification to ICD-9 Procedure Codes</title>
            <pubDate>4/13/2012 2:46:58 PM</pubDate>
            <link>http://www.ahima.org/downloads/pdfs/advocacy/AHIMA%20comments_CM_procedure_0312.pdf</link>
            <author>[email protected] /cdn-cgi/l/email-protection</author>
            <category>News - Alerts</category>
            <description>The American Health Information Management Association (AHIMA) respectfully submits the following comments on the proposed procedure code modifications presented at the ICD-9-CM Coordination and Maintenance (C&M) Committee meeting held on March 5.</description>
        </item><item>
            <title>AHIMA Foundation Establishes Research Innovation and Leadership Institute</title>
            <pubDate>4/13/2012 2:47:47 PM</pubDate>
            <link>http://ahimafoundation.org/PolicyResearch/RILI.aspx</link>
            <author>[email protected] /cdn-cgi/l/email-protection</author>
            <category>News - Alerts</category>
            <description>For the HIM profession to remain relevant and influential we must have a dynamic and expanding knowledge base and defined set of desired skills and expertise. 
To remain relevant we need to expand our knowledge base and stakeout our content area of expertise through mission and discipline critical research. This research must meet standards of scientific rigor and set the foundation for knowledge creation, innovative concept development, and thought leadership. 

To increase influence we need to disseminate knowledge through scholarly processes and publications that inform best practices and influence policy makers. Scholarship must demonstrate our unique expertise and content knowledge base within the healthcare industry. Furthermore, knowledge transfer or dissemination will increase AHIMA brand recognition and enhance brand prestige and prominence. 

To sustain a systematic research initiative AHIMA has established a centralized, high performing Research Innovation and Leadership Institute (RILI) as an enduring mission critical component of the AHIMA Foundation.
</description>
        </item>
    </channel>
</rss>

PHP代码:

<?php

if ( !function_exists( 'strip_html_tags' ) ){   function strip_html_tags( $text )
{
    $text = preg_replace(
        array(
          // Remove invisible content
            '@<head[^>]*?>.*?</head>@siu',
            '@<style[^>]*?>.*?</style>@siu',
            '@<script[^>]*?.*?</script>@siu',
            '@<object[^>]*?.*?</object>@siu',
            '@<embed[^>]*?.*?</embed>@siu',
            '@<applet[^>]*?.*?</applet>@siu',
            '@<noframes[^>]*?.*?</noframes>@siu',
            '@<noscript[^>]*?.*?</noscript>@siu',
            '@<noembed[^>]*?.*?</noembed>@siu',
          // Add line breaks before and after blocks
            '@</?((address)|(blockquote)|(center)|(del))@iu',
            '@</?((div)|(h[1-9])|(ins)|(isindex)|(p)|(pre))@iu',
            '@</?((dir)|(dl)|(dt)|(dd)|(li)|(menu)|(ol)|(ul))@iu',
            '@</?((table)|(th)|(td)|(caption))@iu',
            '@</?((form)|(button)|(fieldset)|(legend)|(input))@iu',
            '@</?((label)|(select)|(optgroup)|(option)|(textarea))@iu',
            '@</?((frameset)|(frame)|(iframe))@iu',
        ),

        array(
            ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
            "\$0", "\$0", "\$0", "\$0", "\$0", "\$0",
            "\$0", "\$0",
        ),
        $text );
    return strip_tags( $text );
} }

class BlogPost {
    var $date;
    var $ts;
    var $link;

    var $title;
    var $text;
    var $author;
    var $summary;
    var $full;
}

class BlogFeed {
    var $posts = array();

    function BlogFeed($file_or_url){
        if(!eregi('^http:', $file_or_url)) {
            $feed_uri = $_SERVER['DOCUMENT_ROOT'] .'/shared/xml/'. $file_or_url;
        } else {
            $feed_uri = $file_or_url;
        }

        $xml_source = file_get_contents($feed_uri);
        $x = simplexml_load_string($xml_source);

        if (count($x) == 0) return;

        foreach($x->channel->item as $item) {
            $post = new BlogPost();
            $post->date = (string) $item->pubDate;
            $post->ts = strtotime($item->pubDate);
            $post->link = (string) $item->link;
            $post->title = (string) $item->title;
            $post->text = (string) strip_html_tags( $item->description );
            $post->full = (string) $item->description;
            $post->author = (string) $item->author;

            $summary = strip_html_tags( $post->text );

            $max_len = 300;
            if(strlen($summary) > $max_len) {
                $summary = substr($summary, 0, $max_len) . '...';
            }

            $post->summary = $summary;

            $this->posts[] = $post;
        }
    }
}

$blogs = array(
'http://www.hhs.gov/rss/news/hhsnews.xml',
'http://ahima.org/RSS/News-Alerts-RSS.aspx',
'http://www.healthcareitnews.com/rss/news',
'http://www.healthcareitnews.com/resource/feed',
'http://www.modernhealthcare.com/section/rss05&mime=xml'
);

foreach( $blogs as $k=>$v ){
    $blog = new BlogFeed($v);
    foreach ( $blog->posts as $one_item ){
        /* ... */
    }
}

好吧,与固定 feed 相比,这可能不太漂亮,但这是一个解决方案:

    $xml_source = str_replace(array("&amp;", "&"), array("&", "&amp;"), file_get_contents($feed_uri));
    $x = simplexml_load_string($xml_source);

首先,我替换&amp;至普通&确保我转换所有&回到&amp; again.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

PHP 解析 XML 时出错(RSS 提要) 的相关文章

  • PHP - 获取base64图像字符串解码并保存为jpg(生成空图像)

    嗨 我实际上是通过 ajax 发送一个 base64 图像字符串到一个 php 脚本 该脚本只是解码字符串并将内容保存为 jpg 文件 但结果是一张空图像 这怎么可能 PHP脚本 uploadedPhotos array photo 1 p
  • Yii2 异常:ApcCache 需要加载 PHP apc 扩展

    在高级模板前端的主配置中配置缓存组件时 我收到异常 在我的 php ini 上启用了扩展 rsults 如何解决此问题 前端 config main php cache gt class gt yii caching ApcCache ke
  • PHP 开发相当于 Mongrel/Webrick 吗?

    PHP 开发中是否有与 Rails 开发期间使用 Mongrel Webrick 等效的方法 我通常在端口 3000 上使用 Mongrel 在开发过程中为我的 Rails 应用程序提供服务 我从事 PHP 开发已经有几年了 据我所知 方法
  • 如何将 HTML 转换为 Markdown?

    我有一个类似 stackoverflow 的网站 有一个文本区域 人们可以在其中写答案 我用这个 PHP 库 http parsedown org 转换降价 我的意思是我使用该函数来转换 italic to i italic i inclu
  • 如何使用 Facebook SDK API 为页面/网址“点赞”?

    我正在使用这段代码 facebook gt api me likes post array url gt http www google com 我收到以下错误 Fatal error Uncaught OAuthException 200
  • 如何解码 eval( gzinflate( base64_decode(

    我已将此代码注入到我的网站中 如何解码尾随字符串 我需要知道发生了什么以及其背后的代码是什么 这应该输出将被执行的代码eval 我希望这就是您正在寻找的
  • Magento - 检查 cms 页面

    我想通过 php 检查页面是否是 Magento 中的 cms page 我需要不同的 cms 页面面包屑 所以我尝试在一个条件下做到这一点 但我不知道如何或在哪里查看 到目前为止 这是我的 breadcrumbs phtml p some
  • 在 C# 中遍历 ANTLR AST 的教程?

    有人知道在 C 中遍历 ANTLR 生成的 AST 的教程吗 我能找到的最接近的是this https web archive org web 20201019210638 http www manuelabadia com blog Pe
  • 使用 XSLT 将 XML 转换为 SQL

    由于我无法控制的原因 我将获得一个 XML 文件和一个 XSLT 文件 该文件可以将 XML 文件转换为 SQL 代码或错误 现在让我们假设我们可以信任提供 XML 文件的人不会在 XML 中包含危险的构造 我什至不知道是否应该使用 Sim
  • 为什么我的 if 语句没有按我预期的方式工作?

    我正在尝试实现以下目标 我向我的 SQL 数据库询问使用SELECT FROM subjects 这样做之后我要求使用数组mysqli fetch assoc 在那之前一切都很好 现在的问题是 当我尝试在每个循环中修改 genero 的值
  • 如何将 XML 文档嵌入到 XHTML 文档中?

    例如 我如何嵌入
  • JavaScript 验证和 PHP 验证?

    我正在使用 jquery 验证插件来验证空表单 我还应该在 PHP 中检查一下以确保 100 正确吗 或者用 javascript 验证就可以了 谢谢 您应该始终在服务器上进行验证 如果用户以某种方式不使用 Javascript 提交表单
  • Joomla 页面中的自定义 php 代码

    我正在尝试将 Joomla 1 5 9 页面中的表源从页面中的硬编码 html 更改为从 SQL 数据库获取信息 执行此操作的正确方法是什么 创建一个新的模型或组件并以某种方式在页面中使用它 我找到了这些 http docs joomla
  • Apache、PHP 和 MySQL 可移植吗?

    我可以在外部硬盘上运行 Apache PHP 和 MySQL 吗 我需要这个 因为我在不同的地方工作 计算机 有时我没有安装和配置所有使用的应用程序 当然可以 XAMPP http www apachefriends org en xamp
  • PHP 数组通过 JSON 转为 jquery 数组

    我有点困惑为什么以下不起作用 get php
  • 如何在 Zend Framework 3 中注册自定义表单视图助手

    我正在将继承的 Zend Framework 2 应用程序迁移到 Zend Framework 3 并且在注册自定义表单视图助手时遇到了一些困难 这些助手在应用程序使用版本 2 时起作用 主要用于添加标签属性以实现可访问性 例如 这是一个自
  • 保存多对多关系,同步/附加不存在?

    我有以下两个多对多关系的模型 use Illuminate Database Eloquent Model class Permission extends Model The database table used by the mode
  • 按钮 - 单击时更改背景颜色

    我的活动中有 8 个按钮 我正在寻找的是 按钮具有默认背景 单击按钮时 背景颜色应更改为其他颜色 这部分非常简单 但是 当我单击任何其他按钮时 第一个按钮的背景颜色应该变回默认颜色 我知道这将使用 选择器状态 来完成 但我不太确定如何实现它
  • AWK:递归下降 CSV 解析器

    响应一个BASH 中的递归下降 CSV 解析器 https codereview stackexchange com questions 11727 need some advice or help with translation and
  • 如何在laravel中注册后自动登录

    我在 laravel 中注册用户时遇到问题 user假设是包含所有数组元素的数组 同时自动登录以下代码结果false 数据库中保存的密码是hash make password user id this gt user model gt ad

随机推荐

  • Python 检查类的实例

    有没有办法检查对象是否是类的实例 不是具体类的实例 而是任何类的实例 我可以检查一个对象不是一个类 不是一个模块 不是一个回溯等 但我对一个简单的解决方案感兴趣 isinstance 是你的朋友吗 它返回一个布尔值 可以通过以下方式使用来检
  • 用于大型密集矩阵乘法的循环平铺/分块

    我想知道是否有人可以向我展示如何有效地使用循环平铺 循环阻塞进行大型密集矩阵乘法 我在做C AB具有 1000x1000 矩阵 我按照维基百科上的循环平铺示例进行操作 但使用平铺得到的结果比不使用平铺的结果更差 http en wikipe
  • 如何让 CakePdf 在 CakePHP 3.x 中工作?

    我已经安装了CakePdf https github com FriendsOfCake CakePdf插件放在 app plugins 文件夹中并遵循所有可能的文档 因此我的设置如下 config bootstrap php Plugin
  • 在 Octave 中创建具有多个绘图的动画

    我正在使用 Octave 编写一个脚本来绘制不同时间段的函数 我希望制作一个情节动画 以便看到随时间的变化 有没有办法保存每个时间点的每个图 以便可以组合所有图来创建此动画 这有点混乱 但您可以执行以下操作 此处适用于 Octave 4 0
  • 将条形码添加到 Report Builder 3.0

    我正在尝试在我的 RDL 报告中嵌入条形码 该报告由Microsoft SQL Server 报表生成器 3 0 我在互联网上找到了几个建议的解决方案 其中之一是添加DLL参考并添加一些代码 但它不起作用 并且总是无法加载DLL 我通过使用
  • 如何从一个视图控制器弹出到另一个视图控制器

    使用 iOS 我现在有 15 个 ViewController 我想从一个 ViewController 弹出到另一个 ViewController 我正在使用这段代码 SecondViewController Sec SecondView
  • Java 在向上转换时如何处理字段? [复制]

    这个问题在这里已经有答案了 可能的重复 阴影的概念 https stackoverflow com questions 3300805 the concept of shadowing 我对 Java 在向上转换期间如何处理类的字段感到困惑
  • ReactiveCommand 完成时的通知

    我正在尝试使用 ReactiveUI ReactiveCommands 来打开和关闭已转换为可观察对象的 gRPC 流 下面显示的代码在某种程度上有效 连接按钮将导致流连接 并且我开始在订阅的 onNext 处理程序中接收数据 断开连接按钮
  • 如何在 Perl 中指定包版本?

    我对 5 10 0 之前的文档和更新的文档之间的冲突建议感到有点困惑version http search cpan org dist version模块 Perl 最佳实践 http oreilly com catalog 9780596
  • 如何获得多维数组中的唯一值

    我在溢出和谷歌上做了很多查找 但没有一个结果适合我的具体情况 我有一个名为 holder 的占位符数组 值如下 Array 0 gt Array id gt 1 pid gt 121 uuid gt 1 1 gt Array id gt 2
  • ui:repeat 内的 selectManyCheckbox 集合知道它属于转发器的哪个元素

    我正在使用 JSF 2 开发一个 Web 应用程序 我的网络应用程序除其他外还包含一系列问题 一次提出一个问题 因此一次可以看到一个问题 并且有多个答案 我使用 h selectManyCheckbox 我将问题和可能的答案存储在 Arra
  • 如何使 Bootstrap 4 卡组每行宽度相同?

    我使用卡片组每行显示 4 张卡片 div class row div class card deck div class card img class card img top img adjusted div class card bod
  • 使用 Powershell 的 .csproj 文件中特定节点中的节点列表

    我想寻求一些帮助 因为我完全迷失了 我想检查 csproj 文件特定部分中的节点是否包含正确的数据 在下面的 xml 片段中 我想取回 PropertyGroup 下属于 Debug x64 配置文件的 title 的值 csproj 文件
  • 在 zsh 中安装 npm 后找不到命令

    我在安装时遇到一些问题vows http vowsjs org通过 zsh 中的 npm 这是我得到的 我尝试使用和不使用 g 选项安装它 你知道这里出了什么问题吗 Desktop sauce node demo master npm in
  • 如何显示合并提交中所做更改的差异?

    当我编写一堆代码时 我没有意识到我正处于合并过程中 现在git log p不会向我显示此更改的差异 它作为合并提交自动提交 我怎样才能让它显示在我的日志差异历史记录中 有点令人失望的是 Git 没有向您显示用于合并的补丁 p 部分原因是由
  • 如何正确更改 Microsoft Azure 中的 SSH 端口?

    我有一个基于 Ubuntu 14 04 LTS 的虚拟机 用于测试 而不是生产服务器 Azure 上默认打开默认 SSH 端口 22 我想将其更改为 12131 我编辑了 SSH 配置文件并将端口更改为 12131 然后通过以下方式重新加载
  • 集成陀螺仪和加速度计读数[重复]

    这个问题在这里已经有答案了 可能的重复 结合陀螺仪和加速度计数据 https stackoverflow com questions 1586658 combine gyroscope and accelerometer data 我读过很
  • 使用 Python 查找单词列表的字谜

    假设我有一个字符串列表 例如 car tree boy girl arc 等等 我想在该列表中找到字谜组 在这种情况下 car arc 我尝试编写代码来循环列表并比较字符串对 但如何解释字母可以采用不同顺序的事实 For the speci
  • 从数据库创建 Grails 域类

    我想从现有数据库创建 grails 域类 通常我是从域类创建数据库 现在我需要从现有数据库模式创建它 如果有可用的命令 请帮助我 我遇到了同样的问题 我发现这个 Grails 插件 https web archive org web 201
  • PHP 解析 XML 时出错(RSS 提要)

    我正在使用基于的 PHP 类在这个答案中找到的 https stackoverflow com questions 250679 best way to parse rss atom feeds with php解析五个 RSS 提要 五人