-
Notifications
You must be signed in to change notification settings - Fork 63
How to generate xml with innerxml
tag?
#29
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
Comments
Currently, one cannot specify an element name (e.g. Code) that should not be parsed further. What you can do is to edit the generated struct by hand and change elements to Potentially, we could have a flag to say which elements should not be descended into further - but then you may have ambiguity (if two elements with the same name appear on different levels of the XML). Similar to the reason, why we have not added type inference just yet: at some point there will be ambiguity and one goal of zek was to keep it (relatively) simple to use (we already have 19 flags). |
just ran into this. with this input: <p>- Did you get me something to give her?<br/>- Yes, this.</p> you get this result: type P struct {
XMLName xml.Name `xml:"p"`
Text string `xml:",chardata"`
Br string `xml:"br"`
} which strips the internal type P struct {
XMLName xml.Name `xml:"p"`
Text string `xml:",chardata"` // or innerxml
Br string `xml:"br"`
} |
Thanks for the issue report. I added a new flag $ cat testdata/w.16.xml
<!-- https://github.com/miku/zek/issues/29#issuecomment-2001630625 -->
<p>- Did you get me something to give her?<br/>- Yes, this.</p>
$ zek -I < testdata/w.16.xml
// P was generated 2024-03-16 11:52:25 by tir on reka with zek 0.1.24.
type P struct {
XMLName xml.Name `xml:"p"`
Text string `xml:",innerxml"`
Br string `xml:"br"`
} This is a tradeoff: simple flag, but no fine-granular control. |
like:
The text was updated successfully, but these errors were encountered: