<commit_before>```javascript
var doc = new DOMParser().parseFromString(document.documentElement.outerHTML, 'text/html');
var result = new XMLSerializer().serializeToString(doc);
```
例子如下：
<p data-height="265" data-theme-id="0" data-slug-hash="xXydOV" data-default-tab="html,result" data-user="lwdgit" data-embed-version="2" data-pen-title="html转xml" class="codepen">See the Pen <a href="https://codepen.io/lwdgit/pen/xXydOV/">html转xml</a> by wen (<a href="https://codepen.io/lwdgit">@lwdgit</a>) on <a href="https://codepen.io">CodePen</a>.</p>
<script async src="https://production-assets.codepen.io/assets/embed/ei.js"></script><commit_msg>update file: _posts/blog/2017-10-15-将html转xml的最简单方法.md<commit_after>```javascript
var doc = new DOMParser().parseFromString(document.documentElement.outerHTML, 'text/html');
var result = new XMLSerializer().serializeToString(doc);
```
例子如下：
<iframe height='548' scrolling='no' title='html转xml' src='//codepen.io/lwdgit/embed/xXydOV/?height=548&theme-id=0&default-tab=js,result&embed-version=2' frameborder='no' allowtransparency='true' allowfullscreen='true' style='width: 100%;'>See the Pen <a href='https://codepen.io/lwdgit/pen/xXydOV/'>html转xml</a> by wen (<a href='https://codepen.io/lwdgit'>@lwdgit</a>) on <a href='https://codepen.io'>CodePen</a>.
</iframe>
{'fraction_non_alphanumeric': 0.20520673813169985, 'fraction_numerical': 0.018376722817764167, 'mean_word_length': 7.16875, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 7, 'lorem ipsum': 0, 'www.': 0, 'xml': 5}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '528358', 'n_tokens_mistral': 502, 'n_tokens_neox': 483, 'n_words': 68}