简体   繁体   English

你可以在html文件中写入xml文件吗

[英]can you write xml file in html file

This may sound too stupid but I have been going crazy for finding that out. 这听起来可能太愚蠢了,但我一直为发现这一点而发疯。 I just need to know how to write XML in HTML file so I can send it using Ajax . 我只需要知道如何XML in HTML文件中编写XML in HTML以便可以使用Ajax发送XML in HTML

I know how to send XML using XMLHttpRequest after I have included external file but that is not what I am trying to do here. 我知道在包含外部文件之后如何使用XMLHttpRequest发送XML但这不是我要在这里进行的工作。 My XML file is really small like 3 tags. 我的XML文件非常小,例如3个标签。 So I don't want to write external file for no reason. 所以我不想无缘无故地写外部文件。 Please explain despite being good with Javascript,CSS, and HTML. 尽管熟练使用Javascript,CSS和HTML,但请进行说明。 I have very limited experince with XML. 我对XML的经验非常有限。 Mostly because I love JSON over all other methods... 主要是因为我喜欢JSON,而不是其他所有方法...

function element(name,content){

    var xml
    if (!content){
        xml='<' + name + '/>'
    }
    else {
        xml='<'+ name + '>' + content + '</' + name + '>'
    }
    return xml
}  

Call this function from a HTML page 从HTML页面调用此函数

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM