开发者

howto get Builder to create <tag></tag> instead of <tag/>

I,m using Builder::XmlMarkup to create xml. I want to create a tag wit开发者_如何学Gohout content because the api force me to create this. If I use a blog

xml.tag do
end

I get what i need

<tag></tag>

but I want it shorter

xml.mytag

this gives me

<mytag/>

but i want

<mytag></mytag>

what do I have to pass as option.

regards Kai


Just pass empty string as a parameter. xml.mytag('')


Why do you want <mytag></mytag> instead of <mytag/>? Since the output is XML, downstream applications should not know or care about the difference.

According to the Infoset spec (Appendix D point 7), "The difference between the two forms of an empty element: <foo/> and <foo></foo>" is not represented in the XML Information Set.

This doesn't answer your "how" question, but if you discover that you actually don't need to do what you're trying to do, it may save you from a difficult and unnecessary wild goose chase.


ok empty string is nice, another one-line-way is empty block I found out.

xml.mytag{}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜