Saturday, 28 September 2013

conversion of xml to html

conversion of xml to html

i hav a string xml that represent some html tags. i want to pick some of
it and insert it to html . typically its the way im doing it in a example:
<html>
<head>
<meta charset="utf-8">
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
</head>
<body>
<div><p>som text</p></div>
<h1>hi there</h1>
<button>click</button>
<script>
xml = '<?xml version="1.0" encoding="utf-8"?><root><html><a
href="#">the new link</a></html></root>';
$xml =$($.parseXML( xml ));
$('button').on('click',function(){
var content = $xml.find('html:first').contents();
content.appendTo('body');
});
</script>
</body>
</html>
but after that something wird happen. i expect it append a link at the end
of the page but i see just a text, its not link. actualy no html tag
works. i used another library to do this instead of jquery like
https://github.com/jindw/xmldom , but the result is same

No comments:

Post a Comment