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 提要) 的相关文章

  • curl 无法获取网页内容,为什么?

    我正在使用curl 脚本转到链接并获取其内容以进行进一步操作 以下是链接和curl脚本
  • 从 json 数组获取值并执行 sql 插入

    这是我的数组 json 1 Device ID a9a3346be4375a92 Date 2012 05 31 Time 15 22 59 Latitude 51 4972912 Longitude 0 1108178 2 Device
  • Godaddy 托管上的 CakePHP 控制台

    我一直在努力让我的 CakePHP 网站在 Godaddy 网格托管 帐户上运行 我的蛋糕应用程序设置是从帐户的子目录托管的 并且可以通过子域访问 我必须调整我的 htaccess 文件才能使其正常工作 现在我需要让 CakePHP 控制台
  • 当用户再次访问同一页面时保持登录状态?

    目前我正在使用会话来登录用户 但是当我关闭浏览器并再次打开它时 我必须再次登录 你如何让用户在 2 周内保持登录状态 那么是通过cookie吗 那么您想要 在这台计算机上记住我 选项吗 这是一种与语言无关的方法 创建一个至少包含以下内容的数
  • 有没有办法在不使用 foreach 或其他函数的情况下在 PHP 中内爆关联数组的键和值?

    我有一个像这样的关联数组 myarray array a gt 1 b gt 2 c gt 3 我想显示数组键和值 如下所示 a is 1 b is 2 c is 3 我不想使用 print r 或 var dump 来执行此操作 我也不想
  • 将 Java 字符串转换为 sql.Timestamp

    收到以下格式的字符串 YYYY MM DD HH MM SS NNNNNN 时间戳来自 DB2 数据库 我需要将其解析为 java sql Timestamp 并且不丢失任何精度 到目前为止 我一直无法找到现有的代码来解析远至微秒的数据 S
  • 如何使用 PHP 查找目录中的前 5 个文件?

    如何使用 PHP 列出按字母顺序排序的目录中的前 5 个文件或目录 Using scandir array slice array filter scandir path to dir is file 0 5 The array filte
  • 如何销毁一个物体?

    据我所知 很少 有两种方法 var new object Then Method 1 Set to null var null Method 2 Unset unset var 还有其他更好的方法吗 我在这里吹毛求疵吗 您正在寻找unset
  • 从单个 javascript 函数向两个不同的 PHP 脚本发送两个 Ajax 请求

    是否可以同时向两个或多个 Php 脚本发送 Ajax 请求 我知道这可以串行实现 从 1 获取响应 然后从另一个获取响应 但我想知道是否可以同时实现 请协助我使用以下代码 function calShowUpload if http rea
  • 如何在PHP中将图像从内存上传到AWS S3?

    所以我目前有一个使用 AWS S3 上传图像的上传系统 这是代码 Upload image to S3 s3 Aws S3 S3Client factory array key gt mykey secret gt myskey try s
  • 返回上一页

    我正在使用表格来 评价 页面 此表单将数据 发布 到其他地方的 php 脚本 我只是想在处理表单后显示一个链接 这将使用户返回到上一页 我可以在 php 脚本中使用 javascript 来执行此操作吗 GF 您可以使用链接来调用histo
  • PHP OOP 静态属性语法错误 [关闭]

    这个问题不太可能对任何未来的访客有帮助 它只与一个较小的地理区域 一个特定的时间点或一个非常狭窄的情况相关 通常不适用于全世界的互联网受众 为了帮助使这个问题更广泛地适用 访问帮助中心 help reopen questions 为什么不
  • 将自定义参数传递给 Symfony2 中的自定义 ValidationConstraint

    我正在 Symfony2 中创建一个表单 表格只包含一个book字段允许用户在列表中进行选择Books实体 我需要检查是否选择了Book属于Author我的控制器里有 public class MyFormType extends Abst
  • PHP URL 验证

    我知道有无数的线程问这个问题 但我一直无法找到一个可以帮助我解决这个问题的线程 我基本上试图解析大约 10 000 000 个 URL 的列表 确保它们根据以下标准有效 然后获取根域 URL 此列表包含您能想象到的几乎所有内容 包括类似的内
  • 使用 PHP 修剪字符串开头的任何零

    用户将在字段中填写与其帐户相关的数字 不幸的是 一些用户会在号码开头添加零来组成六位数字 例如 000123 001234 而其他用户则不会 例如 123 1234 我想 修剪 前面带有零前缀的用户的数字 因此如果用户输入 000123 它
  • 将价格格式设置为逗号分隔

    在我的数据库中 我有类似的值 256 23 200 33 89 33 133 45 我必须将这些值乘以千 然后将结果格式化为价格 逗号分隔 256 23 x 1000 256230 I want to show this as 256 23
  • 如果文件名减去扩展名,.htaccess url 重写行为将被覆盖。与网址相同

    我正在尝试整理 URL 并从中删除 php 扩展名等 我位于网站的基本文件夹中 因此没有可以优先处理的父 htaccess 文件或其他文件 这是我的 htaccess 代码 RewriteEngine On RewriteRule give
  • 如何根据另一个下拉列表中的选择动态填充下拉列表中的选项?

    我有一个表 其中包含类别信息 例如产品 我已将它们列在下拉菜单中 现在 我需要做的是 在下一个下拉菜单中列出所选类别的子类别 我希望 javascript 是必需的 但我对 javascript 还不太熟悉 将非常感谢您的帮助 你应该使用
  • Magento 中的子域 htaccess 问题

    public html www domain com public html subdomain subdomain domain com public html htaccess public html subdomain htacces
  • 如何检查号码是否是巴基斯坦用户的手机号码而不是固定电话号码

    我所做的是从开头删除 92 或 0092 并使用以下代码检查它是否是巴基斯坦人的有效手机号码 if preg match 3 0 4 0 9 number 1 Pakistani mobile number else not a pakis

随机推荐

  • 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 提要 五人