我正在尝试在Go中为一个大型xml文件(dblp.xml)编写一个非常简单的解析器,其摘录如下:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE dblp SYSTEM "dblp.dtd">
<dblp>
<article key="journals/cacm/Gentry10" mdate="2010-04-26">
<author>Craig Gentry</author>
<title>Computing arbitrary functions of encrypted data.</title>
<pages>97-105</pages>
<year>2010</year>
<volume>53</volume>
<journal>Commun. ACM</journal>
<number>3</number>
<ee>http://doi.acm.org/10.1145/1666420.1666444</ee>
<url>db/journals/cacm/cacm53.html#Gentry10</url>
</article>
<article key="journals/cacm/Gentry10" mdate="2010-04-26">
<author>Craig Gentry Number2</author>
<title>Computing arbitrary functions of encrypted data.</title>
<pages>97-105</pages>
<year>2010</year>
<volume>53</volume>
<journal>Commun. ACM</journal>
<number>3</number>
<ee>http://doi.acm.org/10.1145/1666420.1666444</ee>
<url>db/journals/cacm/cacm53.html#Gentry10</url>
</article>
</dblp>
Run Code Online (Sandbox Code Playgroud)
我的代码如下所示,看起来有些东西正在进行xml.Unmarshal(byteValue, &articles),因为我无法在输出中获得任何xml的值.你能帮我解决我的代码有什么问题吗?
package main
import (
"encoding/xml"
"fmt"
"io/ioutil"
"os"
)
// Contains the array of articles in the dblp xml
type Dblp struct { …Run Code Online (Sandbox Code Playgroud)