Reading the inner text of an XML element using Go -
I'm trying to read the XML file in go using the XML package ().
My problem is that I am not sure how to read the internal text of an element. I load the document in XML. Call the parser and then the parser. To go to the token () file. I check to see if the token is using the following:
token, err: = parser.Token () if element, ok: = token (Xml.StartElement); Ok [/ i can read the element name and attributes in the process as an initial element here] if charData, ok: = token (Xml.CharData); OK {how to read text data as text in text? }
The xml.CharData type is defined as:
type charadata [byte]
But I can not use the alphabetic variable as an array of bytes to convert to a string. The only way to define the CharData is to copy the token, but it only gives a second copy of a fourfold variable. I have tried some things, but they do not compile:
Is there another way of XML behavior? Chiradata variable as a piece of bytes?
Depending on the language spec, you have to do the string ([] byte Should be enabled
.
[] byte
-> string
is a special case for type conversion, generally, the only underlying type of new type and original type ( I.e. xml.CharData and [] byte)
Comments
Post a Comment