开发者

W3C equivalent for JavaScript DOMParser node.xml?

I'm using DOMParser to 开发者_运维问答parse some raw xml data loaded into a string. Given a particular Node object, I need to obtain the raw xml data for that node and everything beneath it in the tree.

For example, given:

<?xml version="1.0" encoding="UTF-8"?>
<root>
    <elem>
        <div>this is some text</div>
    </elem>
</root>

...and given a node object representing the <elem> element, I need to obtain:

    "<elem>
        <div>this is some text</div>
    </elem>"

...as a string.


W3C provides DOM Level 3 Load/Save spec but I am not aware of any native implementation in browsers. However, you can use de factor standard component XMLSerializer to get the xml content out.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜