亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Golang:解析組的 XML 元素值和屬性

Golang:解析組的 XML 元素值和屬性

Go
精慕HU 2021-06-29 13:05:20
我有一個像這樣的 XML 結構:<RootLevel status="new" timestamp="1383259529" xmlns="http://someplace.com">    <Item active="1" status="new" itemid="451254">        <SubItem active="1" recent="false" usertext="No idea" id="78421">            <SubItemField active="1" ready="no" type="1">1.4</SubItemField>            <SubItemField active="1" ready="yes" type="2">4.5</SubItemField>        </SubItem>    </Item></RootLevel>我不知道如何收集 SubItemField 元素的值和屬性,我的代碼類似于:type RootLEvel struct {    XMLName xml.Name `xml:"RootLevel"`    ...    Item    []Item}type Item struct {    ...    SubItem   []SubItem}type SubItem struct {    ...    SubItemField    []SubItemField}type SubItemField struct {    Active bool `xml:"active,attr"`    Ready string `xml:"ready,attr"`}我需要屬性和值,但獲得我知道的值的唯一方法就是使用SubItemField  []float32而不是我的自定義類型。我正在使用 xml.Unmarshal 順便說一句。任何想法?
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 428 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號