Extract XML to XHTML to apply CSS’s easiest way

I want to know how to parse the XML documents returned by the search so that I can style them with CSS on the website. I assume that I need to convert the XML to xhtml first, and then set it accordingly The style of the elements. I need them to display xhtml.

Does anyone know the easiest way? I know that using CSS to construct XML directly is not a good habit, which is why I think there must be a javascript solution.

Any insights would be great, thank you!

d

If you import XML via AJAX, then you only need to do A few key things…

1.) The parent element needs an XML namespace…

2.) Use W3C standard methods (appendChild, importNode, responseXML) and non-proprietary Microsoft methods (innerHTML, responseText) Or your application will be treated as Notepad text instead of the actual application. This is roughly what the code looks like…

if (window.XMLHttpRequest) {var xmlhttp = new XMLHttpRequest();}
else if (window.ActiveXObject) {try {xmlhttp = new ActiveXObject('Msxml2.XMLHTTP')} catch (e) {try{xmlhttp = new ActiveXObject('Microsoft.XMLHTTP') } catch (e){}}}

xmlhttp.open('GET',url,true);
xmlhttp.send(null);

xmlhttp .onreadystatechange=function()
{
if (xmlhttp.readyState=='4')
{
var xmlDoc=xmlhttp.responseXML;
document.importNode( xmlDoc.getElementsByTagName('div')[0],true),id_container_obj);
}

By using the correct code, you can design the imported XHTML without a doubt. To demonstrate, please visit my website in my profile and click on the website option in the upper right corner.

I want to know how to parse the XML documents returned by the search so that I can style them with CSS on the website. I assume I need to convert the XML to xhtml first, and then set accordingly The style of the elements. I need them to display xhtml.

Does anyone know the easiest way? I know that using CSS to construct XML directly is not a good habit, which is why I think there must be a javascript solution.

Any insights would be great, thank you!

d

If you import XML via AJAX, then you only need to do a few key things…

1.) The parent element needs an XML namespace…

2.) Use W3C standard methods (appendChild, importNode, responseXML) and non-proprietary Microsoft methods (innerHTML, responseText) or your application will be treated as Notepad text Rather than the actual application. This is roughly what the code looks like…

if (window.XMLHttpRequest) {var xmlhttp = new XMLHttpRequest();}
else if (window.ActiveXObject) {try {xmlhttp = new ActiveXObject('Msxml2.XMLHTTP')} catch (e) {try{xmlhttp = new ActiveXObject('Microsoft.XMLHTTP')} catch (e){}}}

xmlhttp.open('GET',url,true);
xmlhttp.send(null);

xmlhttp.onreadystatechange=function()
{< br /> if (xmlhttp.readyState=='4')
{
var xmlDoc=xmlhttp.responseXML;
document.importNode(xmlDoc.getElementsByTagName('div')[0], true),id_container_obj);
}

By using the correct code, you can design the imported XHTML without a doubt. For a live demo, please visit my profile in my profile Website, and then click the website option in the upper right corner.

Leave a Comment

Your email address will not be published.