Html to xml converter javascript

Is it possible to convert all div child information into XML or JSON using JavaScript?

$("#droppable").droppable({
drop : function(event, ui) {
    var id = $(ui.draggable).attr("id");
    var cloneObj = $((ui.draggable).clone());
    $(cloneObj).removeClass("draggable ui-draggable");
    if (id === "txt") {
        inputOBj = document.createElement("input");
        inputOBj.setAttribute("id", "txt" + i);
        $("#droppable").append(inputOBj);
    } else if (id == "combo") {
        inputOBj = document.createElement("select");
        inputOBj.setAttribute("id", "select" + i);
        console.log("");
    }
  });

abatishchev

96.2k82 gold badges294 silver badges428 bronze badges

asked Dec 24, 2012 at 12:36

3

I believe you can use XMLSerializer to do this.

var yourString = new XMLSerializer().serializeToString(cloneObj[0]);

answered Dec 24, 2012 at 12:46

Html to xml converter javascript

SemicolonSemicolon

6,0332 gold badges29 silver badges38 bronze badges

0

there is property called outerHTML. It Sets or retrieves the object and its content in HTML. U can use it in following way. e.g:

$(document).ready(function() {  
    $('#p').click(function() {
        alert($('#p')[0].outerHTML);
    }); 
});

tip: p is your any tag ID in body of page.

abatishchev

96.2k82 gold badges294 silver badges428 bronze badges

answered Dec 26, 2012 at 4:15

Oomph FortuityOomph Fortuity

5,49010 gold badges37 silver badges86 bronze badges

1

Convert HTML to XML online helps to convert HTML Table to xml which saves a lot a time. Copy, Paste and Convert to XML. It traverse the DOM and look for tables from the HTML data.

What can you do with HTML to XML?

  • This tool helps you to get plain xml from html table very quickly without writing single line of code.
  • From HTML to XML free allows loading the Website URL which has tables converting to XML. Click on the URL button, Enter URL and Submit.
  • Parsing HTML into XML supports loading the HTML File to transform to XML. Click on the Upload button and select File.
  • HTML to Plain XML Converter Online works well on Windows, MAC, Linux, Google Chrome, Firefox, Edge, and Safari.

Example of HTML

HTML with Table Try it.

firstName lastName
Tom Cruise
Maria Sharapova
James Bond

Converted HTML 2 XML


	<0>
		Tom
		Cruise
	
	<1>
		Maria
		Sharapova
	
	<2>
		James
		Bond
	

For Advanced Users

HTML with Table External URL

Load HTML External URL in Browser URL like this https://codebeautify.org/html-to-xml-converter?url=external-url

https://codebeautify.org/html-to-xml-converter?url=https://gist.githubusercontent.com/cbmgit/644916fb1e435ddc367233c6d785652f/raw/html-table.html

How do I convert HTML to XML?

How to convert HTML to XML ?.
1Upload HTML File. Choose the HTML document you wish to convert..
2Select HTML Tools. Before clicking the Convert button, use any available HTML to XML tools..
3Download Your XML. Let the conversion process finish, then download your XML document..

What is JavaScript XML?

XML parsing in JavaScript is defined as it is one kind of package or library of the software which provides an interface for the client applications to work with an XML document and it is used in JavaScript to transform the XML document into readable form, nowadays in many browsers, the XML parser is already available ...

Can you convert HTML to JavaScript?

Insert your HTML text into the text box by typing it or cut and paste. Then to convert it to JavaScript that is usable in an HTML document, click the 'Convert HTML -> JavaScript' button; the converted code will appear in the same box. The 'Clear Text' button will erase everything in the text box.

How do I convert HTML to xhtml?

To Covert a Site from HTML to XHTML:.
You must add a DOCTYPE definition to the top of every page of code. ... .
All tags and attributes must be lowercase..
All attribute values must have quotation marks around them. ... .
You must close empty tags from the HTML. ... .
Have the web site validated..