DOM object of XML, to HTML

MogycyncGok

New Member
I have a XML code with a XML table\[code\]<displayTable><tr><td> items </td><..></displayTable>\[/code\]its structured just exactly like a table in HTML but the name of the element is different.I then parseXML it with jQuery, and get a DOM object. But now when I'm trying to get the html elements of the tables, but i don't get the HTML table(no errors, I get the items within the tags) when using \[code\].text()\[/code\] and \[code\].html()\[/code\]... anyone know why? EDIT: Sorry for the confusion.So its similar to this js. I want the HTML code from the XML. So just the A...At the line&&& it produces "Uncaught TypeError: Cannot call method 'replace' of undefined" error var str = "A";\[code\]$('#code-analysis').html(str);console.log(str);// parse string of XML codevar xmlString = str;var xml = $.parseXML( xmlString );$xml = $( xml );// print to table in consolevar displayTable = $xml.find( 'displayTable' ).children;console.log ( displayTable );// print table.text() to console, // but not in the HTML format // just the text within the elementvar displayTableText = displayTable.text();console.log ( displayTableText ); // A// print table.html() to consolevar displayTableHTML = displayTable.html(); // &&&console.log ( displayTableHTML ); \[/code\]
 
Back
Top