-
Notifications
You must be signed in to change notification settings - Fork 18k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
proposal: encoding/xml: Unmarshal comment with tag #39357
Comments
I understand this request to be asking for a way to collect comment text in XML unmarshaling, same as the ability to collect inner CDATA text. That's interesting but I am not sure whether we should go down that road. If there is any data structure to unmarshal in the XML, it seems like it should be in non-comment form. It would be especially problematic to have to attach comments to the XML elements that follow them, as in the example ( Note that using xml.Token it is possible to read the data stream and do whatever you like. If you know that there is a stream of comment/object/comment/object/... then you can use an xml.Decoder to use Decode.Token to get the comment, then Decoder.Decode to get the object, and repeat. |
This proposal has been added to the active column of the proposals project |
Based on the discussion above, this proposal seems like a likely decline. |
There may not be other languages that support parsing comments. Golang is the only one I know, but connecting comments together is not very practical. Developers can do it through complex coding, but this is a bit difficult for ordinary people. I think this way of parsing is similar to parsing documentation comments on functions, which is very elegant and practical. |
This is indeed the case. My demand actually comes from parsing the stock code written by others in a large project. They use this kind of annotation method to describe the service configuration. I need to find all the services and bring an annotation explanation. I started I didn't have time to study how to write it. In order to realize it quickly, regular expressions were used at the time, but it was quite complicated😄. |
No change in consensus, so declined. |
What did you do?
What did you expect to see?
if
then
What did you see instead?
if
then
The text was updated successfully, but these errors were encountered: