VTD-XML 可以接受字符串作为输入吗?
嘿,我正在尝试使用 VTD-XML 来解析作为字符串提供的 XML,但我找不到如何执行此操作。任何帮助将不胜感激。
Hey, I'm trying to use VTD-XML to parse XML given to it as a String, but I can't find how to do it. Any help would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
VTD-XML 库似乎可以让您读取字节数组数据。在这种情况下,我建议使用正确的编码将字符串转换为字节。
如果在 XML 字符串的开头标明编码:
则使用该编码:
如果没有编码,请使用编码,因为 VTD-XML 知道如何解码字节:
请注意,在后一种情况下,您可以使用任何有效的编码因为内存中的字符串与编码无关(它采用 UTF-16 格式,但当您请求字节时,它将被转换)。
It seems VTD-XML library lets you read byte array data. I'd suggest in that case, convert the String to bytes using the correct encoding.
If there's an encoding signaled in the begining of the XML string:
Then use that:
If there's not an encoding, please use one, for VTD-XML know how to decode the bytes:
Note that in the later case you can use any valid encoding because the string you have in memory is encoding-agnosting (it's in UTF-16 but when you ask for the bytes it will be converted).
VTD-XML 不接受字符串,因为字符串暗示 UCS-16 编码,这意味着它不是真正的 xml 文档.. 根据规范的定义,xml 通常采用 utf-8、ascii、iso-8859-1 编码或 UTF-16LE 或 BE 格式...我的答案有意义吗?
VTD-XML doesn't accept a string because string implies UCS-16 encoding, which means it is not really a xml document.. as defined by the spec, xml is usually encoded in utf-8, ascii, iso-8859-1 or UTF-16LE or BE format... does my answer make sense?