0

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.

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. My XML file is really small like 3 tags. So I don't want to write external file for no reason. Please explain despite being good with Javascript,CSS, and HTML. I have very limited experince with XML. Mostly because I love JSON over all other methods...

Thalaivar
  • 23,282
  • 5
  • 60
  • 71
Muhammad Umer
  • 17,263
  • 19
  • 97
  • 168
  • Write `XML` in a `HTML` File? – MackieeE Mar 01 '14 at 19:13
  • 1
    You can definitely do it with Javacsript forming XML and posting it in using Ajax – user3004356 Mar 01 '14 at 19:13
  • @MackieeE as i understand i have to send xml using ajax..what is the best way to do it. I think if i could just like write it and then send it would be nice :D – Muhammad Umer Mar 01 '14 at 19:15
  • 2
    How would you solve it with a small piece of JSON? And how is XML different? – GolezTrol Mar 01 '14 at 19:19
  • Javascript - > http://www.codeproject.com/Articles/3337/XML-and-JavaScript – Thalaivar Mar 01 '14 at 19:19
  • guys don't close this i am totally clueless about xml...and it's not my choice i am trying to learn ebay api which accepts xml data. – Muhammad Umer Mar 01 '14 at 19:23
  • As far as i understood this http://stackoverflow.com/questions/9713058/sending-post-data-with-a-xmlhttprequest should be close to what you are looking for. Your question would be better if it would include what you have tried and where you are stuck. If your question is specific to ebay why not point to the documentation and show your code? – surfmuggle Mar 01 '14 at 19:27
  • that link shows how to send data as parameters with ajax post..what i want to know is how to send xml data with ajax. – Muhammad Umer Mar 01 '14 at 21:26

1 Answers1

0
function element(name,content){

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

Call this function from a HTML page

user3004356
  • 870
  • 4
  • 16
  • 49