第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

Golang xml 不會(huì)解組

Golang xml 不會(huì)解組

Go
蕪湖不蕪 2021-11-22 18:28:11
我試圖解組下面有 go 操場(chǎng)的代碼。data.DocumentType 總是返回 0 并且應(yīng)該返回內(nèi)部 xml 4. 有人能告訴我為什么這不起作用嗎?package mainimport (    "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
查看完整描述

2 回答

?
aluckdog

TA貢獻(xiàn)1847條經(jīng)驗(yàn) 獲得超7個(gè)贊

I tried to do as much i could please suggest and help . 

I use this method please comment and suggest.  

https://play.golang.org/p/kb0HF8ykHW


  package main;

    import (

        "fmt"

        "encoding/xml"  

    )


    func main(){

    dxml := `

    <?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/>

                <rptOwnerCity>EAST RUTHERFORD</rptOwnerCity>

                <rptOwnerState>NJ</rptOwnerState>

                <rptOwnerZipCode>07073</rptOwnerZipCode>

                <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>

                    <transactionFormType>4</transactionFormType>

                    <transactionCode>S</transactionCode>

                    <equitySwapInvolved>0</equitySwapInvolved>

                </transactionCoding>

                <transactionAmounts>

                    <transactionShares>

                        <value>10000</value>

                    </transactionShares>

                    <transactionPricePerShare>

                        <value>50.18</value>

                        <footnoteId id="F1"/>

                    </transactionPricePerShare>

                    <transactionAcquiredDisposedCode>

                        <value>D</value>

                    </transactionAcquiredDisposedCode>

                </transactionAmounts>

                <postTransactionAmounts>

                    <sharesOwnedFollowingTransaction>

                        <value>36562</value>

                    </sharesOwnedFollowingTransaction>

                </postTransactionAmounts>

                <ownershipNature>

                    <directOrIndirectOwnership>

                        <value>D</value>

                    </directOrIndirectOwnership>

                    <natureOfOwnership>

                        <value/>

                    </natureOfOwnership>

                </ownershipNature>

            </nonDerivativeTransaction>

        </nonDerivativeTable>

        <footnotes>

            <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>

        </footnotes>

        <remarks/>

        <ownerSignature>

            <signatureName>Samantha Hanley for William B. Korb by POA</signatureName>

            <signatureDate>2015-11-20</signatureDate>

        </ownerSignature>

    </ownershipDocument>


    `


        defer func() {

            if errD := recover(); errD != nil {

                    fmt.Println("!!!!!!!!!!!!!!!!Panic Occured and Recovered in func main(), Error Info: ", errD)

                }

        }()


        var Owner Ownershipdocs 


        err := xml.Unmarshal([]byte(dxml), &Owner)

            fmt.Println("xml.unmarshal error info :",err)

                fmt.Println("SchemaVersion : ",Owner.SchemaVersion)

                fmt.Println("DocumentType : ",Owner.DocumentType)

                fmt.Println("PeriodOfReport : ",Owner.PeriodOfReport)

                fmt.Println("IssuerCik : ",Owner.IssuerCik)

                fmt.Println("IssuerName : ",Owner.IssuerName)

                fmt.Println("IssuerTradingSymbol : ",Owner.IssuerTradingSymbol)

                fmt.Println("RptOwnerCik : ",Owner.RptOwnerCik)

                fmt.Println("RptOwnerName : ",Owner.RptOwnerName)

                fmt.Println("RptOwnerStreet1 : ",Owner.RptOwnerStreet1)

                fmt.Println("RptOwnerCity :  ",Owner.RptOwnerCity)

                fmt.Println("RptOwnerState : ",Owner.RptOwnerState)

                fmt.Println("RptOwnerZipCode : ",Owner.RptOwnerZipCode)

                fmt.Println("IsDirector : ",Owner.IsDirector)   

                fmt.Println("IsOfficer :  ",Owner.IsOfficer)


                fmt.Println("IsTenPercentOwner : ",Owner.IsTenPercentOwner)

                fmt.Println("IsOther : ",Owner.IsOther)

                fmt.Println("SecurityTitleValue : ",Owner.SecurityTitleValue)

                fmt.Println("TransactionDatevalue : ",Owner.TransactionDatevalue)

                fmt.Println("TransactionFormType : ",Owner.TransactionFormType)

                fmt.Println("TransactionCode : ",Owner.TransactionCode)

                fmt.Println("EquitySwapInvolved : ",Owner.EquitySwapInvolved)

                fmt.Println("TransactionSharesValue : ",Owner.TransactionSharesValue)

                fmt.Println("TransactionPricePerShareValue : ",Owner.TransactionPricePerShareValue)

                fmt.Println("TransactionPricePerSharefootnoteId :  ",Owner.TransactionPricePerSharefootnoteId)

                fmt.Println("TransactionAcquiredDisposedCodeValue : ",Owner.TransactionAcquiredDisposedCodeValue)


                fmt.Println("Footnote.Footnote : ",Owner.Footnote.Footnote)

                fmt.Println("OwnerSignaturesignatureName : ",Owner.OwnerSignaturesignatureName)

                fmt.Println("OwnerSignaturesignatureDate    : ",Owner.OwnerSignaturesignatureDate)  


    }


    type Ownershipdocs struct{

        SchemaVersion           string `xml:"schemaVersion"`

        DocumentType            string `xml:"documentType"`

        PeriodOfReport          string `xml:"periodOfReport"`

        IssuerCik               string `xml:"issuer>issuerCik"`

        IssuerName              string `xml:"issuer>issuerName"`

        IssuerTradingSymbol     string `xml:"issuer>issuerTradingSymbol"`

        RptOwnerCik             string `xml:"reportingOwner>reportingOwnerId>rptOwnerCik"`

        RptOwnerName            string `xml:"reportingOwner>reportingOwnerId>rptOwnerName"`


        RptOwnerStreet1         string `xml:"reportingOwner>reportingOwnerAddress>rptOwnerStreet1"`

        RptOwnerCity            string `xml:"reportingOwner>reportingOwnerAddress>rptOwnerCity"`

        RptOwnerState           string `xml:"reportingOwner>reportingOwnerAddress>rptOwnerState"`

        RptOwnerZipCode         string `xml:"reportingOwner>reportingOwnerAddress>rptOwnerZipCode"`


        IsDirector              string `xml:"reportingOwner>reportingOwnerRelationship>isDirector"`

        IsOfficer               string `xml:"reportingOwner>reportingOwnerRelationship>isOfficer"`  

        IsTenPercentOwner       string `xml:"reportingOwner>reportingOwnerRelationship>isTenPercentOwner"`

        IsOther                 string `xml:"reportingOwner>reportingOwnerRelationship>isOther"`        


        SecurityTitleValue      string `xml:"nonDerivativeTable>nonDerivativeTransaction>securityTitle>value"`

        TransactionDatevalue    string `xml:"nonDerivativeTable>nonDerivativeTransaction>transactionDate>value"`    

        TransactionFormType     string `xml:"nonDerivativeTable>nonDerivativeTransaction>transactionCoding>transactionFormType"`

        TransactionCode         string `xml:"nonDerivativeTable>nonDerivativeTransaction>transactionCoding>transactionCode"`

        EquitySwapInvolved      string `xml:"nonDerivativeTable>nonDerivativeTransaction>transactionCoding>equitySwapInvolved"`



        TransactionSharesValue                  string `xml:"nonDerivativeTable>nonDerivativeTransaction>transactionAmounts>transactionShares>value"`

        TransactionPricePerShareValue           string `xml:"nonDerivativeTable>nonDerivativeTransaction>transactionAmounts>transactionPricePerShare>value"`

        TransactionPricePerSharefootnoteId      string `xml:"nonDerivativeTable>nonDerivativeTransaction>transactionAmounts>transactionPricePerShare>footnoteId"`

        TransactionAcquiredDisposedCodeValue    string `xml:"nonDerivativeTable>nonDerivativeTransaction>transactionAmounts>transactionAcquiredDisposedCode>value"`


        SharesOwnedFollowingTransactionValue    string `xml:"nonDerivativeTable>nonDerivativeTransaction>ownershipNature>directOrIndirectOwnership>value"`


        Footnote                                Footnotes   `xml:"footnotes"`

        OwnerSignaturesignatureName             string       `xml:"ownerSignature>signatureName"`

        OwnerSignaturesignatureDate             string       `xml:"ownerSignature>signatureDate"`


    }


    type Footnotes struct{

        ID          string `xml:"id,attr"`

        Footnote    string `xml:"footnote"`


    }


查看完整回答
反對(duì) 回復(fù) 2021-11-22
?
森欄

TA貢獻(xiàn)1810條經(jīng)驗(yàn) 獲得超5個(gè)贊

刪除 上的innerxml標(biāo)記DocumentType,并為其指定要匹配的元素的名稱 ( xml:"documentType")。從xml 庫(kù)文檔

如果結(jié)構(gòu)具有類型為[]bytestring帶有標(biāo)記“,innerxml”的字段,則Unmarshal累積嵌套在該字段中元素內(nèi)的原始 XML。其余規(guī)則仍然適用。

您不需要存儲(chǔ)未處理的 XML。您正在尋找該字段的值,因此您不需要標(biāo)簽。

工作版本

*edit:就此而言,",innerxml"標(biāo)簽也會(huì)破壞SchemaVersion字段——沒有匹配的元素(因?yàn)?code>SchemaVersion是字符串),它存儲(chǔ)整個(gè)文檔。


查看完整回答
反對(duì) 回復(fù) 2021-11-22
  • 2 回答
  • 0 關(guān)注
  • 189 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)