You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if len(el.Children) == 0 {
if len(el.Content) > 0 {
e.w.Write(el.Content)
} else {
return nil
}
}
The Marshal function only writes out .Content (which includes the chardata) if there are no child elements. I could write out .Content unconditionally, but the problem is that .Content also contains the XML for child elements, and it will not reflect any changes made to the tree after Parse.
I'm not sure what's best here. I guess we could include xml.CharData in the decode switch here, add a .CharData field to Element, and work that into the encoder. The Marshal output would look different from the source document, but I think it should be good enough for the example here.
When I parse the xml above using the following code ,the code is as follows:
The corresponding structure is as follows:
The parsed result "module" is lost!!
ps:but when I use the native parser. "moudle" is not lost.
Why?
The text was updated successfully, but these errors were encountered: