How to Load XML File Contents using Javascript?

I'm looking for a way to load an XML file's contents directly into a Javascript variable. Say I have the following directory structure: /index.html /loader.js /file.xml In `index.html`, there is a `` tag, whose contents should be replaced with the contents of the XML file. So if the XML file contains: Item One Item Two Then after the dynamic load, the HTML would be: ... ... ... My question is, what function can I use in `loader.js` to load the contents straight into a variable? I have used XmlHttpRequests and the ActiveX XMLDOM parser, but all just give me a structural data model that I then have to sort through to find my elements. I don't need to parse anything, I just want to obtain all the file contents. **Note:** HTML/Javascript only, no server-side code.
This can be combersome to do with plain-old JavaScript, are you using any frameworks? (before someone says "use jQuery"...)

以上就是How to Load XML File Contents using Javascript?的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准