Skip to content

Failed to parse chardata. #129

Open
Open
@yuanhuili

Description

@yuanhuili
  • I have an xml file, and a part of the string is as follows:
    <userdatatype>module
        <dataTypeEnum schemanode="" description="" declareType="ExportAll" name="ISOLATIONMODE"/>
    </userdatatype>

When I parse the xml above using the following code ,the code is as follows:

	ele,err:=xmltree.Parse(data)
	xmltree.Unmarshal(ele,v)
	if err != nil {
		fmt.Printf("error: %v", err)
		return
	}

The corresponding structure is as follows:

type Cuserdatatype struct {
	XMLName       xml.Name       `sxml:"userdatatype,omitempty" json:"userdatatype,omitempty"`
	CdataTypeEnum *CdataTypeEnum `xml:"dataTypeEnum,omitempty" json:"dataTypeEnum,omitempty"`
	CString        string         `xml:",chardata" json:",omitempty"`
}

The parsed result "module" is lost!!
image

ps:but when I use the native parser. "moudle" is not lost.

 xml.Unmarshal(data, v)

image

Why?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions