我试图解组下面有 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
aluckdog
森栏
相关分类