Create XML element without closing tag

前端 未结 1 2012
孤独总比滥情好
孤独总比滥情好 2020-12-11 12:26

I have this nested golang struct:

// TierRequest is the outer most XML envelope of soap request
type TierRequest struc         


        
相关标签:
1条回答
  • 2020-12-11 13:29

    There is no difference at the XML level between an element with no content and an end-tag:

    <soapenv:Header></soapenv:Header>
    

    and an empty element tag:

    <soapenv:Header/>
    

    To control which form is used, you'd have to treat the data as text rather than as XML, but better not to worry about a difference that makes no difference.


    [Added for completeness]

    ...other than an obscure and antiquated recommendation

    For interoperability, the empty-element tag should be used, and should only be used, for elements which are declared EMPTY.

    regarding interoperability with SGML:

    for interoperability

    [Definition: Marks a sentence describing a non-binding recommendation included to increase the chances that XML documents can be processed by the existing installed base of SGML processors which predate the WebSGML Adaptations Annex to ISO 8879.]

    0 讨论(0)
提交回复
热议问题