在iPhone中读取的XML Feed中使用英镑符号 [英] Using the British pound sign in an XML feed to be read by an iPhone

查看:108
本文介绍了在iPhone中读取的XML Feed中使用英镑符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个用于iPhone应用程序的基于Web的UTF-8 XML Feed。

I have created a web-based UTF-8 XML feed for use in an iPhone application.

在网络浏览器中查看时,如果Feed包含英国英镑符号,我得到一个讨厌的XML错误:XML解析错误:未定义的实体

When viewing in a web browser, if the feed contains a British Pound sign, I get a nasty XML error: XML Parsing Error: undefined entity

但实际文件似乎是可读的。

However the actual file seems to be readable.

1。一个iPhone NSParser能够读取该文件还是会由于这个字符而失败?

2。是否可以对XML的井号进行编码?

推荐答案

我的最终解决方案似乎适用于所有情况是输入时替换所有特殊字符。

My final solution which seems to work in all cases is to replace all special chars as they are input.

  public function xmlEntities($text)
  {
    $search = array('&','<','>','"','\'', chr(163), chr(128), chr(165));
    $replace = array('&amp;', '&lt;', '&gt;', '&quot;', '&apos;', '&#163;', '&#8364;', '&#165;');

    $text = str_replace($search, $replace, $text);

    return $text;
  }

这篇关于在iPhone中读取的XML Feed中使用英镑符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆