XML:非法字符:“/”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1243624/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
XML:Illegal characters: " /"
提问by Pavan
I am trying to send a value like <Somevalue = "Value A/B">through XML.As "/" comes under illegal character,I tired to encode like ⁄for slash but it is not working.Is there anyway to do the same?
我正在尝试<Somevalue = "Value A/B">通过 XML发送一个值。由于“/”属于非法字符,我厌倦了像⁄斜线一样编码,但它不起作用。无论如何也要这样做吗?
回答by Rob Levine
The xml sample you have given there is not valid, irrespective of the slash (which is valid)
无论斜杠如何(有效),您在那里提供的 xml 示例都无效
I'm guessing it should either be something like
我猜它应该是这样的
<Somevalue>Value A/B</Somevalue>
OR
或者
<Somevalue value="Value A/B"/>
In any case - until you fix your xml, it won't work.
在任何情况下 - 在你修复你的 xml 之前,它都不会工作。
回答by Jon Skeet
"/" isn't an illegal character in XML at all. It may be illegal for the particular service you're using, however.
“/”在 XML 中根本不是非法字符。但是,您使用的特定服务可能是非法的。
Could you give more context? I strongly suspect this isn't really an XML question, but a service-specific question. I suspect if you look at the error message you're getting, it will talk about invalid values rather than illegal XML. (If you could post that error message in full, it would be helpful too.)
你能提供更多的上下文吗?我强烈怀疑这不是一个真正的 XML 问题,而是一个特定于服务的问题。我怀疑如果您查看收到的错误消息,它会谈论无效值而不是非法 XML。(如果您可以完整地发布该错误消息,也会有所帮助。)
回答by Iain Galloway
Forwardslash isn't a special character in XML. The snipped you posted is well-formed. What's saying it's illegal?
正斜杠不是 XML 中的特殊字符。您发布的剪辑格式良好。什么叫违法?
You could try using / (2F being the hex for the ASCII character code for the forwardslash character).
你可以尝试使用 / (2F 是正斜杠字符的 ASCII 字符代码的十六进制)。

