XML非法属性值 [英] XML Illegal Attribute Value

查看:266
本文介绍了XML非法属性值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在java中使用SAX解析器来读取一些XML。我给它的XML有问题并导致解析失败。这是错误消息:

11-18 10:25:37.290:W / System.err(3712):org.xml.sax .SAXParseException:非法:< (位置:START_TAG< question text ='null'> @ 1:23 in java.io.InputStreamReader@4074c678)



我有一种感觉,它不喜欢XML中的字符串中有一些HTML标签。从语法的角度来看,我认为引号内的任何内容都会被忽略。另外,这里使用单引号是否有效?以下是一个例子:

 <测验> 
< question text =< img src ='// files / alex / hilltf.PNG'alt ='hill'style ='max-width:400px'/>在地图上以剪切表示。 >
< answer text =1/>
< / question>
< / quiz>


解决方案

错误消息是正确的。 < 必须是标签的开始,并且不能出现在字符串中。它必须是& lt; 。我不相信报价是一个问题。


I am using the SAX parser in java to read some XML. The XML I am giving it has problems and is causing the parse to fail. Here is the error message:

11-18 10:25:37.290: W/System.err(3712): org.xml.sax.SAXParseException: Illegal: "<" inside attribute value (position:START_TAG <question text='null'>@1:23 in java.io.InputStreamReader@4074c678)

I have a feeling that it does not like the fact that I have some HTML tags inside of a string in the XML. I would think that anything inside the quotes gets ignored from a syntax standpoint. Also, is it valid to use single quotes here? Here is an example:

<quiz>
    <question text="<img src='//files/alex/hilltf.PNG' alt='hill' style='max-width:400px' />  is represented on map by cut. ">
        <answer text="1"/>
        <answer text="2" correct="true"/>
    </question>
</quiz>

解决方案

The error message is correct. A < must be the start of a tag, and cannot appear inside a string. It must be &lt; instead. I don't believe the quotes is a problem.

这篇关于XML非法属性值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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