dai*_*no3 0 xml go

给定以下结构:

type book struct {
    XMLName xml.Name   `xml:"DailyAct"`
    Symbol     string  `xml:"TradeInstrId,attr"`
    EntityId   string  `xml:"EntityId,attr"`
    AssetClass string  `xml:"AssetClass,attr"`
    Open       int     `xml:"Open"`
    High       int     `xml:"High"`
    Low        int     `xml:"Low"`
    Close      int     `xml:"Close"`
    // Type      string `` //I'll leave this for another question
}
Run Code Online (Sandbox Code Playgroud)

我当前的XML:

  <DailyAct EntityId="foo" AssetClass="bar" TradeInstrId="Symbol" >
      <Open>2</Open>
      <High>3</High>
      <Low>1</Low>
      <Close>5</Close>
  </DailyAct>
Run Code Online (Sandbox Code Playgroud)

但是,我需要重新调整结构的某些字段的用途(或以其他方式生成xml)以实现:

<DailyAct EntityId="foo" AssetClass="bar" TradeInstrId="Symbol">
  <Open Price="2" Type="IND"/>
  <High Price="6" Type="IND"/>
  <Low Price="1" Type="IND"/>
  <Close Price="4" Type="IND"/>
</DailyAct>
Run Code Online (Sandbox Code Playgroud)
&errors.errorString{s:"xml: DailyAct>Open chain not valid with Price,attr flag"} (actual)
type book struct {
    //...
    Open       int     `xml:"DailyAct>Open,Price,attr>"`
    //...
}
Run Code Online (Sandbox Code Playgroud)

我发现了这个讨论,而谷歌搜索周围,所以我要去目前可能不可行