Golang xml 不会解组

我试图解组下面有 go 操场的代码。data.DocumentType 总是返回 0 并且应该返回内部 xml 4. 有人能告诉我为什么这不起作用吗?


package main


import (

    "encoding/xml"

    "fmt"


)


type doc struct {

    XMLName       xml.Name `xml:"ownershipDocument"`

    SchemaVersion string   `xml:",innerxml"`

    DocumentType  int      `xml:",innerxml"`

}


func main() {

    var Data doc

    xml.Unmarshal([]byte(VV), &Data)

    fmt.Println(Data.DocumentType)


}


const VV = `<?xml version="1.0"?>

<ownershipDocument>


    <schemaVersion>X0306</schemaVersion>


    <documentType>4</documentType>


    <periodOfReport>2015-11-18</periodOfReport>


    <issuer>

        <issuerCik>0000820081</issuerCik>

        <issuerName>CAMBREX CORP</issuerName>

        <issuerTradingSymbol>CBM</issuerTradingSymbol>

    </issuer>


    <reportingOwner>

        <reportingOwnerId>

            <rptOwnerCik>0001227832</rptOwnerCik>

            <rptOwnerName>KORB WILLIAM B</rptOwnerName>

        </reportingOwnerId>

        <reportingOwnerAddress>

            <rptOwnerStreet1>1 MEADOWLANDS PLAZA</rptOwnerStreet1>

            <rptOwnerStreet2></rptOwnerStreet2>

            <rptOwnerCity>EAST RUTHERFORD</rptOwnerCity>

            <rptOwnerState>NJ</rptOwnerState>

            <rptOwnerZipCode>07073</rptOwnerZipCode>

            <rptOwnerStateDescription></rptOwnerStateDescription>

        </reportingOwnerAddress>

        <reportingOwnerRelationship>

            <isDirector>1</isDirector>

            <isOfficer>0</isOfficer>

            <isTenPercentOwner>0</isTenPercentOwner>

            <isOther>0</isOther>

        </reportingOwnerRelationship>

    </reportingOwner>


    <nonDerivativeTable>

        <nonDerivativeTransaction>

            <securityTitle>

                <value>Common Stock</value>

            </securityTitle>

            <transactionDate>

                <value>2015-11-18</value>

            </transactionDate>

            <transactionCoding>

http://play.golang.org/p/nJbAF0zKSJ


芜湖不芜
浏览 164回答 2
2回答

aluckdog

I tried to do as much i could please suggest and help .&nbsp;I use this method please comment and suggest.&nbsp;&nbsp;https://play.golang.org/p/kb0HF8ykHW&nbsp; package main;&nbsp; &nbsp; import (&nbsp; &nbsp; &nbsp; &nbsp; "fmt"&nbsp; &nbsp; &nbsp; &nbsp; "encoding/xml"&nbsp;&nbsp;&nbsp; &nbsp; )&nbsp; &nbsp; func main(){&nbsp; &nbsp; dxml := `&nbsp; &nbsp; <?xml version="1.0"?>&nbsp; &nbsp; <ownershipDocument>&nbsp; &nbsp; &nbsp; &nbsp; <schemaVersion>X0306</schemaVersion>&nbsp; &nbsp; &nbsp; &nbsp; <documentType>4</documentType>&nbsp; &nbsp; &nbsp; &nbsp; <periodOfReport>2015-11-18</periodOfReport>&nbsp; &nbsp; &nbsp; &nbsp; <issuer>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <issuerCik>0000820081</issuerCik>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <issuerName>CAMBREX CORP</issuerName>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <issuerTradingSymbol>CBM</issuerTradingSymbol>&nbsp; &nbsp; &nbsp; &nbsp; </issuer>&nbsp; &nbsp; &nbsp; &nbsp; <reportingOwner>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <reportingOwnerId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <rptOwnerCik>0001227832</rptOwnerCik>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <rptOwnerName>KORB WILLIAM B</rptOwnerName>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </reportingOwnerId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <reportingOwnerAddress>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <rptOwnerStreet1>1 MEADOWLANDS PLAZA</rptOwnerStreet1>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <rptOwnerStreet2/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <rptOwnerCity>EAST RUTHERFORD</rptOwnerCity>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <rptOwnerState>NJ</rptOwnerState>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <rptOwnerZipCode>07073</rptOwnerZipCode>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <rptOwnerStateDescription/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </reportingOwnerAddress>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <reportingOwnerRelationship>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <isDirector>1</isDirector>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <isOfficer>0</isOfficer>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <isTenPercentOwner>0</isTenPercentOwner>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <isOther>0</isOther>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </reportingOwnerRelationship>&nbsp; &nbsp; &nbsp; &nbsp; </reportingOwner>&nbsp; &nbsp; &nbsp; &nbsp; <nonDerivativeTable>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <nonDerivativeTransaction>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <securityTitle>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <value>Common Stock</value>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </securityTitle>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <transactionDate>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <value>2015-11-18</value>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </transactionDate>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <transactionCoding>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <transactionFormType>4</transactionFormType>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <transactionCode>S</transactionCode>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <equitySwapInvolved>0</equitySwapInvolved>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </transactionCoding>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <transactionAmounts>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <transactionShares>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <value>10000</value>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </transactionShares>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <transactionPricePerShare>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <value>50.18</value>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <footnoteId id="F1"/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </transactionPricePerShare>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <transactionAcquiredDisposedCode>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <value>D</value>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </transactionAcquiredDisposedCode>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </transactionAmounts>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <postTransactionAmounts>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <sharesOwnedFollowingTransaction>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <value>36562</value>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </sharesOwnedFollowingTransaction>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </postTransactionAmounts>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ownershipNature>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <directOrIndirectOwnership>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <value>D</value>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </directOrIndirectOwnership>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <natureOfOwnership>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <value/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </natureOfOwnership>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </ownershipNature>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </nonDerivativeTransaction>&nbsp; &nbsp; &nbsp; &nbsp; </nonDerivativeTable>&nbsp; &nbsp; &nbsp; &nbsp; <footnotes>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <footnote id="F1">The price reported in Column 4 is a weighted average price. These shares were sold in multiple transactions at prices ranging from $50.00 to $50.58 inclusive. The reporting person undertakes to provide to Cambrex Corporation, any security holder of Cambrex Corporation, or the staff of the Securities and Exchange Commission, upon request, full information regarding the number of shares sold at each separate price within the range set forth in this Footnote 1 to this Form 4.</footnote>&nbsp; &nbsp; &nbsp; &nbsp; </footnotes>&nbsp; &nbsp; &nbsp; &nbsp; <remarks/>&nbsp; &nbsp; &nbsp; &nbsp; <ownerSignature>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <signatureName>Samantha Hanley for William B. Korb by POA</signatureName>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <signatureDate>2015-11-20</signatureDate>&nbsp; &nbsp; &nbsp; &nbsp; </ownerSignature>&nbsp; &nbsp; </ownershipDocument>&nbsp; &nbsp; `&nbsp; &nbsp; &nbsp; &nbsp; defer func() {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if errD := recover(); errD != nil {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fmt.Println("!!!!!!!!!!!!!!!!Panic Occured and Recovered in func main(), Error Info: ", errD)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; }()&nbsp; &nbsp; &nbsp; &nbsp; var Owner Ownershipdocs&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; err := xml.Unmarshal([]byte(dxml), &Owner)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fmt.Println("xml.unmarshal error info :",err)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fmt.Println("SchemaVersion : ",Owner.SchemaVersion)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fmt.Println("DocumentType : ",Owner.DocumentType)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fmt.Println("PeriodOfReport : ",Owner.PeriodOfReport)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fmt.Println("IssuerCik : ",Owner.IssuerCik)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fmt.Println("IssuerName : ",Owner.IssuerName)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fmt.Println("IssuerTradingSymbol : ",Owner.IssuerTradingSymbol)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fmt.Println("RptOwnerCik : ",Owner.RptOwnerCik)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fmt.Println("RptOwnerName : ",Owner.RptOwnerName)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fmt.Println("RptOwnerStreet1 : ",Owner.RptOwnerStreet1)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fmt.Println("RptOwnerCity :&nbsp; ",Owner.RptOwnerCity)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fmt.Println("RptOwnerState : ",Owner.RptOwnerState)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fmt.Println("RptOwnerZipCode : ",Owner.RptOwnerZipCode)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fmt.Println("IsDirector : ",Owner.IsDirector)&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fmt.Println("IsOfficer :&nbsp; ",Owner.IsOfficer)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fmt.Println("IsTenPercentOwner : ",Owner.IsTenPercentOwner)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fmt.Println("IsOther : ",Owner.IsOther)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fmt.Println("SecurityTitleValue : ",Owner.SecurityTitleValue)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fmt.Println("TransactionDatevalue : ",Owner.TransactionDatevalue)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fmt.Println("TransactionFormType : ",Owner.TransactionFormType)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fmt.Println("TransactionCode : ",Owner.TransactionCode)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fmt.Println("EquitySwapInvolved : ",Owner.EquitySwapInvolved)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fmt.Println("TransactionSharesValue : ",Owner.TransactionSharesValue)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fmt.Println("TransactionPricePerShareValue : ",Owner.TransactionPricePerShareValue)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fmt.Println("TransactionPricePerSharefootnoteId :&nbsp; ",Owner.TransactionPricePerSharefootnoteId)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fmt.Println("TransactionAcquiredDisposedCodeValue : ",Owner.TransactionAcquiredDisposedCodeValue)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fmt.Println("Footnote.Footnote : ",Owner.Footnote.Footnote)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fmt.Println("OwnerSignaturesignatureName : ",Owner.OwnerSignaturesignatureName)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fmt.Println("OwnerSignaturesignatureDate&nbsp; &nbsp; : ",Owner.OwnerSignaturesignatureDate)&nbsp;&nbsp;&nbsp; &nbsp; }&nbsp; &nbsp; type Ownershipdocs struct{&nbsp; &nbsp; &nbsp; &nbsp; SchemaVersion&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;string `xml:"schemaVersion"`&nbsp; &nbsp; &nbsp; &nbsp; DocumentType&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string `xml:"documentType"`&nbsp; &nbsp; &nbsp; &nbsp; PeriodOfReport&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string `xml:"periodOfReport"`&nbsp; &nbsp; &nbsp; &nbsp; IssuerCik&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;string `xml:"issuer>issuerCik"`&nbsp; &nbsp; &nbsp; &nbsp; IssuerName&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string `xml:"issuer>issuerName"`&nbsp; &nbsp; &nbsp; &nbsp; IssuerTradingSymbol&nbsp; &nbsp; &nbsp;string `xml:"issuer>issuerTradingSymbol"`&nbsp; &nbsp; &nbsp; &nbsp; RptOwnerCik&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;string `xml:"reportingOwner>reportingOwnerId>rptOwnerCik"`&nbsp; &nbsp; &nbsp; &nbsp; RptOwnerName&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string `xml:"reportingOwner>reportingOwnerId>rptOwnerName"`&nbsp; &nbsp; &nbsp; &nbsp; RptOwnerStreet1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;string `xml:"reportingOwner>reportingOwnerAddress>rptOwnerStreet1"`&nbsp; &nbsp; &nbsp; &nbsp; RptOwnerCity&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string `xml:"reportingOwner>reportingOwnerAddress>rptOwnerCity"`&nbsp; &nbsp; &nbsp; &nbsp; RptOwnerState&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;string `xml:"reportingOwner>reportingOwnerAddress>rptOwnerState"`&nbsp; &nbsp; &nbsp; &nbsp; RptOwnerZipCode&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;string `xml:"reportingOwner>reportingOwnerAddress>rptOwnerZipCode"`&nbsp; &nbsp; &nbsp; &nbsp; IsDirector&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string `xml:"reportingOwner>reportingOwnerRelationship>isDirector"`&nbsp; &nbsp; &nbsp; &nbsp; IsOfficer&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;string `xml:"reportingOwner>reportingOwnerRelationship>isOfficer"`&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; IsTenPercentOwner&nbsp; &nbsp; &nbsp; &nbsp;string `xml:"reportingOwner>reportingOwnerRelationship>isTenPercentOwner"`&nbsp; &nbsp; &nbsp; &nbsp; IsOther&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;string `xml:"reportingOwner>reportingOwnerRelationship>isOther"`&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; SecurityTitleValue&nbsp; &nbsp; &nbsp; string `xml:"nonDerivativeTable>nonDerivativeTransaction>securityTitle>value"`&nbsp; &nbsp; &nbsp; &nbsp; TransactionDatevalue&nbsp; &nbsp; string `xml:"nonDerivativeTable>nonDerivativeTransaction>transactionDate>value"`&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; TransactionFormType&nbsp; &nbsp; &nbsp;string `xml:"nonDerivativeTable>nonDerivativeTransaction>transactionCoding>transactionFormType"`&nbsp; &nbsp; &nbsp; &nbsp; TransactionCode&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;string `xml:"nonDerivativeTable>nonDerivativeTransaction>transactionCoding>transactionCode"`&nbsp; &nbsp; &nbsp; &nbsp; EquitySwapInvolved&nbsp; &nbsp; &nbsp; string `xml:"nonDerivativeTable>nonDerivativeTransaction>transactionCoding>equitySwapInvolved"`&nbsp; &nbsp; &nbsp; &nbsp; TransactionSharesValue&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string `xml:"nonDerivativeTable>nonDerivativeTransaction>transactionAmounts>transactionShares>value"`&nbsp; &nbsp; &nbsp; &nbsp; TransactionPricePerShareValue&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;string `xml:"nonDerivativeTable>nonDerivativeTransaction>transactionAmounts>transactionPricePerShare>value"`&nbsp; &nbsp; &nbsp; &nbsp; TransactionPricePerSharefootnoteId&nbsp; &nbsp; &nbsp; string `xml:"nonDerivativeTable>nonDerivativeTransaction>transactionAmounts>transactionPricePerShare>footnoteId"`&nbsp; &nbsp; &nbsp; &nbsp; TransactionAcquiredDisposedCodeValue&nbsp; &nbsp; string `xml:"nonDerivativeTable>nonDerivativeTransaction>transactionAmounts>transactionAcquiredDisposedCode>value"`&nbsp; &nbsp; &nbsp; &nbsp; SharesOwnedFollowingTransactionValue&nbsp; &nbsp; string `xml:"nonDerivativeTable>nonDerivativeTransaction>ownershipNature>directOrIndirectOwnership>value"`&nbsp; &nbsp; &nbsp; &nbsp; Footnote&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Footnotes&nbsp; &nbsp;`xml:"footnotes"`&nbsp; &nbsp; &nbsp; &nbsp; OwnerSignaturesignatureName&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;string&nbsp; &nbsp; &nbsp; &nbsp;`xml:"ownerSignature>signatureName"`&nbsp; &nbsp; &nbsp; &nbsp; OwnerSignaturesignatureDate&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;string&nbsp; &nbsp; &nbsp; &nbsp;`xml:"ownerSignature>signatureDate"`&nbsp; &nbsp; }&nbsp; &nbsp; type Footnotes struct{&nbsp; &nbsp; &nbsp; &nbsp; ID&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string `xml:"id,attr"`&nbsp; &nbsp; &nbsp; &nbsp; Footnote&nbsp; &nbsp; string `xml:"footnote"`&nbsp; &nbsp; }

森栏

删除 上的innerxml标记DocumentType,并为其指定要匹配的元素的名称 (&nbsp;xml:"documentType")。从xml 库文档:如果结构具有类型为[]byte或string带有标记“,innerxml”的字段,则Unmarshal累积嵌套在该字段中元素内的原始 XML。其余规则仍然适用。您不需要存储未处理的 XML。您正在寻找该字段的值,因此您不需要标签。工作版本*edit:就此而言,",innerxml"标签也会破坏SchemaVersion字段——没有匹配的元素(因为SchemaVersion是字符串),它存储整个文档。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Go