![微信图片_20190620112039.png](https://static.studygolang.com/190620/8b2b59ba29567c4bb57fa266a591664c.png)![微信图片_20190620112053.png](https://static.studygolang.com/190620/3bf23bf981933e2dcde8304a5d1cd558.png)
使用结构体来定义,转成xml的时候如何能转成图一的那种,<Item />。定义的DTD是这种:
<?xml version="1.0" encoding="GBK"?>
<!-- Host_AntiVirus_Event_1.00.dtd -->
<!ELEMENT Events (Event+)>
<!ATTLIST Events
count CDATA #REQUIRED
>
<!ELEMENT Event (Item+)>
<!ATTLIST Event
code CDATA #REQUIRED
version CDATA #REQUIRED
id CDATA #IMPLIED
description CDATA #IMPLIED
>
<!ELEMENT Item EMPTY>
<!ATTLIST Item
key CDATA #REQUIRED
value CDATA #REQUIRED
>
然后需要处理成:
<Item key =”alert.detect_time” value=”2005-09-02T19:31:00+08:00”/>
有疑问加站长微信联系(非本文作者)