相关疑难解决方法(0)

我需要在XML文档中转义哪些字符?

必须在XML文档中转义哪些字符,或者在哪里可以找到这样的列表?

xml escaping character

889
推荐指数
8
解决办法
92万
查看次数

如何在XML中转义"&"?

可能重复:
如何在XML中转义&符号?

我写

 <string name="magazine">Newspaper & Magazines</string>
Run Code Online (Sandbox Code Playgroud)

在strings.xml中

但是编译器说:

The entity name must immediately follow the '&' in the entity reference.    strings.xml /OOReaderWidget/res/values  line 9  Android XML Format Problem
Run Code Online (Sandbox Code Playgroud)

那么如何在strings.xml中显示"&"?谢谢!

xml

195
推荐指数
3
解决办法
36万
查看次数

我真的需要将'&'编码为'&amp;'吗?

&在我的网站上使用带有HTML5和UTF-8的符号<title>.Google在其SERP上显示的&符号很好,其标题中的所有浏览器也是如此.

http://validator.w3.org给了我这个:

并没有开始角色参考.(可能应该被转义为&amp;.)

我真的需要做&amp;吗?

我并不是为了验证我的页面而感到困惑,但是我很想听听人们对此的看法,以及它是否重要以及为什么.

html validation html5 utf-8 character-encoding

194
推荐指数
9
解决办法
34万
查看次数

如何在App.Config中编写URI字符串

我正在做一个Windows Service.在Service每晚都要donwload东西,为此我要放置URI在App.config万一我以后需要改变它.

我想在App.Config中编写一个URI.什么使它无效,我应该如何处理?

<appSettings>
    <add key="fooUriString" 
         value="https://foo.bar.baz/download/DownloadStream?id=5486cfb8c50c9f9a2c1bc43daf7ddeed&login=null&password=null"/>
</appSettings>
Run Code Online (Sandbox Code Playgroud)

我的错误:

- Entity 'login' not defined
- Expecting ';'
- Entity 'password' not defined
- Application Configuration file "App.config" is invalid. An error occurred
Run Code Online (Sandbox Code Playgroud)

c# configuration uri windows-services app-config

29
推荐指数
3
解决办法
2万
查看次数

&符号中的XML错误(&)

我有一个php文件,它打印一个基于MySql数据库的xml.

每次出现&符号时,我都会收到错误.

这是一些PHP:

$query = mysql_query($sql);

$_xmlrows = '';

while ($row = mysql_fetch_array($query)) {
    $_xmlrows .= xmlrowtemplate($row);
}

function xmlrowtemplate($dbrow){
    return "<AD>
              <CATEGORY>".$dbrow['category']."</CATEGORY>
            </AD>
}
Run Code Online (Sandbox Code Playgroud)

输出是我想要的,即文件输出正确的类别,但仍然给出错误.

错误说:xmlParseEntityRef:没有名字

然后它指向一个&符号的确切字符.

只有在$dbrow['category']带有&符号的东西时才会抱怨,例如:" 汽车和卡车 ",或" 电脑和电话 ".

有谁知道问题是什么?

顺便说一句:我在所有文档中都将编码设置为UTF-8,以及xml输出.

html php xml mysql database

21
推荐指数
2
解决办法
4万
查看次数

由于存在'&'字符,Python给出'格式不正确的xml'错误

我正在使用Python读取xml文件.但我的xml文件包含&字符,因为在运行我的Python代码时,它会出现以下错误:

xml.parsers.expat.ExpatError: not well-formed (invalid token):
Run Code Online (Sandbox Code Playgroud)

有没有办法忽略&python 的检查?

python xml ampersand

7
推荐指数
1
解决办法
1万
查看次数

XML url 中的 &amp; 符号未通过

我很难解决 URL 中与号 (&) 的这个小问题......我正在序列化 XML,如下所示......

    var ser = new XmlSerializer(typeof(response));
    using (var reader = XmlReader.Create(url))
    {
        response employeeResults = (response)ser.Deserialize(reader); //<<error when i pass with ampersand
    }
Run Code Online (Sandbox Code Playgroud)

如果&url 中没有,上面的代码工作正常,否则它会抛出一个错误(见下文)

我没有问题序列化这个网址:

http://api.host.com/api/employees.xml/?&search=john
Run Code Online (Sandbox Code Playgroud)

这个网址有问题:

http://api.host.com/api/employees.xml/?&max=20&page=10
Run Code Online (Sandbox Code Playgroud)

我得到的错误是:

`There is an error in XML document (1, 389).`
Run Code Online (Sandbox Code Playgroud)

PS:我确实尝试过传球&#038;,也尝试过&#38or#026&amp;- 没有运气。

.net c# xml xml-serialization xmlserializer

4
推荐指数
1
解决办法
5715
查看次数

如何解析带有特殊字符的xml?专门用于&符号

我从文本框中获取数据并将其更改为 xml 格式并将其存储在数据库中。为了允许特殊字符,我编写了 javascript 函数来用它的 html 实体替换特殊字符。

 "     &quot;
 &     &amp;
 <     &lt;
 >     &gt;
Run Code Online (Sandbox Code Playgroud)

对于“引号,小于,大于”其工作正常。对于“&”,它显示了 xml 解析器错误,我使用 javascript 用它的实体替换了特殊字符

  string.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/'/g, "\\'");

  for "&" allow showing warning but it get stored in data base. please help me to sort out this problem . 


 i begin with string.replace(/&/g, '&amp;') even though i am getting 
Run Code Online (Sandbox Code Playgroud)

警告:SimpleXMLElement::__construct():实体:第 9 行:解析器错误:EntityRef:期望 ';' 在 /var/www/ 我也试过这个 &amp; 正如此链接中提到的stackoverflow.com/questions/1328538/...
之后没有警告,但在保存在 db 中时,它保存为“ab & cd”

javascript xml special-characters

3
推荐指数
1
解决办法
6619
查看次数

如何解决XML中的&符号(&)转换问题?

我使用的XMLDocument创建XML文件,但是当XML节点获得"和"数据,将其转换在"号(&)放大器;" 但我需要'&'的实际价值,任何人都可以告诉我如何实现它?

结果:

xml

1
推荐指数
2
解决办法
2万
查看次数