Trying to parse some XML and then insert specific parts into various HTML elements.
I'm using the innerHTML routine and whenever I insert <br>
tags, formatting as <br />
or <br></br>
in the XML document it automatically ignores the /
and formats it to <br>
XML source:
<br />
I have tried various things like replacing the /
with the HTML character codes, but still it inserts <br>
.
I want <br />
OR <br></br>
Why isn't this working?
EDIT:
XML File:
<?xml version="1.0" encoding="iso-8859-1"?>
<questionContainer>
<title>What is this?</title>
<body>
<br />
This is the login form to access the KayPop beta. New beta testers are accepted weekly, find our more or...
<br / ><br / >
<a href="#">Sign up here!</a>
</body>
</questionContainer>
Javascript Routine:
function insertXML()
{
$.ajax ({
type: "GET",
url: 'cd_catalog.xml',
dataType: "xml",
success: function( xml )
{
$(xml).find('questionContainer').each(function(){
var title = $(this).find('title').text();
document.getElementById('q-T').innerHTML = title;
var bodyText = $(this).find('body').text();
document.getElementById('q-B').innerHTML = bodyText;
});
}
});
}
Procuded HTML (viewed in Chrome -> Inspect Element):
` -- `
` is not valid; it has to be a self-closing tag. – SDC Jan 07 '13 at 15:05
` in the DOM tree, that's perfectly fine. Or where exactly are you seeing the `
`s and how do you "insert specific parts into various HTML elements"? – Felix Kling Jan 07 '13 at 15:05
` *is* valid XHTML. – BoltClock Jan 07 '13 at 15:07