【发布时间】:2022-11-29 20:51:55
【问题描述】:
我的 XML 文件顶部有一些处理指令,如下所示:
<?ID Object="AUTO_REPORT_OBJECT" Version="1.0"?>
我想使用 Go 库读取对象和版本属性值。我正在使用 Go 1.19。
我的 XML 文件是这样的:
<?xml version="1.0" encoding="UTF-8"?>
<?ID Object="AUTO_REPORT_OBJECT" Version="1.0"?>
<?xml-stylesheet type="text/xsl" href="../XML/ProdRep.xsl"?>
<!DOCTYPE Auto_Report SYSTEM "../XML/ProdRep.dtd" [
<!ELEMENT Auto_Report (Production_Report+)>
]>
<Auto_Report>
<Production_Report Type="AUTO">
... more tags
</Production_Report>
</Auto_Report>
<?End?>
【问题讨论】:
-
为了使问题更清楚,请发布一个实际的 XML 示例(带有根元素)。
<?ID Object="AUTO_REPORT_OBJECT" Version="1.0"?>本身不是格式正确的 XML。 -
使用
xml.Decoder并按token 处理即可获取处理说明。显示您要处理的实际 XML 文档,以及您希望从中得到什么。 -
完成了,抱歉。我编辑了添加整个 XML 文件的问题。
标签: xml go processing-instruction