Erlang xml 用位语法解析
我正在尝试为某种 API 编写一个特定的 xml 解析器,我想知道是否可以在没有像 xmerl 这样的现有 xml 解析器的情况下让它工作。仅使用位语法来实现它有多可行?是否有任何在线文档显示如何开始以这种方式解析 xml?
I am trying to write a specific xml parser for some kind of API and I was wondering if I can get it working without the existing xml parsers like xmerl. How feasible would be to implement it using only bit syntax and is there any online doc where shows how you can get started on parsing xml this way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是不可行的,XML 解析器可用是有原因的,如果可行的话专用解析器就不会存在。位语法仅适用于固定位/字节顺序的情况。 XML 不强制要求属性的顺序,并且大多数人没有意识到 XML 规范也不强制要求同级元素的顺序。因此,尝试使用位语法来匹配任何内容并不能仅针对属性的无序性质来处理所有可能的 XML 输入,更不用说无序的同级元素了。只需使用 XML 解析器即可,这不是您想死在山上的地方。
It is not feasible, XML parsers are available for a reason, it if was feasible then the dedicated parsers would not exist. Bit syntax is only good for when the order of the bits/bytes is fixed. XML does not mandate order of attributes, and most people don't realize that the XML spec is does not mandate order of sibling elements either. So trying to match anything with the bit syntax would not work with all possible inputs of XML just with the unordered nature of attributes, much less unordered sibling elements. Just use an XML parser, this isn't a hill you want to die on.