mikemaccana
mikemaccana

Reputation: 123610

Cross platform Javascript XML tree creation, with namespaces and xpath?

I'd like to create XML documents in a portable way in JavaScript. Coming from a Python background, I'm familiar with libraries like LXML and ElementTree, which give

Essentially, I'm looking for a neat XML creation library that works across browsers. Any recommendations?

Upvotes: 1

Views: 435

Answers (1)

Martin Honnen
Martin Honnen

Reputation: 167716

If that is client-side Javascript in the browser then for creating namespace aware XML DOM documents you can use the W3C DOM Level 2 with browsers like Mozilla, Opera, Safari, Chrome and the MSXML DOM with IE (before IE 9 comes out). I do have two examples in my blog explaining the W3C DOM Level 2 namespace aware createElementNS and the MSXML createNode. Based on that you might be able to implement your own wrapper methods to hide the differences between createElementNS and createNode.

Upvotes: 1

Related Questions