Jump to content

xml and <br />


iswariak

Recommended Posts

Hi all,I have the text "Courtesy: TSDA <br /> (at Dharmapuri museum)." in the xml file. I have to display the text in two lines. The text "(at Dharmapuri museum)." is missing in the html file. Please tell me how to provide carriage returns while displaying the text in html from xml files?XML file:<?xml version="1.0" encoding="utf-8"?><imageData state_code="tn" site_name="kuruvinayanapalli" period="3"><row><imgName>tn_0382_3_ia_kuruvinayanapalli_antiq1_01.jpg</imgName><imgCaption>Kuruvinayanapalli: Iron Implements</imgCaption><imgDesc>Courtesy: TSDA <br /> (at Dharmapuri museum).</imgDesc></row></imageData>Displaying xml data in html file using javascript sdesc = nxmlDoc.getElementsByTagName("imgDesc");document.getElementById("idesc").childNodes[0].nodeValue = sdesc[slno].childNodes[0].nodeValue;

Link to comment
Share on other sites

Hi all,I have the text "Courtesy: TSDA <br /> (at Dharmapuri museum)." in the xml file. I have to display the text in two lines. The text "(at Dharmapuri museum)." is missing in the html file. Please tell me how to provide carriage returns while displaying the text in html from xml files?XML file:<?xml version="1.0" encoding="utf-8"?><imageData state_code="tn" site_name="kuruvinayanapalli" period="3"><row><imgName>tn_0382_3_ia_kuruvinayanapalli_antiq1_01.jpg</imgName><imgCaption>Kuruvinayanapalli: Iron Implements</imgCaption><imgDesc>Courtesy: TSDA <br /> (at Dharmapuri museum).</imgDesc></row></imageData>Displaying xml data in html file using javascript sdesc = nxmlDoc.getElementsByTagName("imgDesc");document.getElementById("idesc").childNodes[0].nodeValue = sdesc[slno].childNodes[0].nodeValue;
To prevent the xml parser from interpreting "<", ">" etc in your data, you can enclose the text in a CDATA section:
<imgDesc><![CDATA[Courtesy: TSDA <br /> (at Dharmapuri museum).]]></imgDesc>

See this page for more info about CDATA sections.

Link to comment
Share on other sites

HiWhen I use the following statementdocument.getElementById("idesc").childNodes[0].nodeValue = sdesc[slno].childNodes[0].nodeValue;The result is Courtesy: TSDA <br /> (at Dharmapuri museum).The text "<br/>" is also displayed instead of coming in a new line.The result should be as follows:Courtesy: TSDA (at Dharmapuri museum).ThanksIswaria

Hi all,I have the text "Courtesy: TSDA <br /> (at Dharmapuri museum)." in the xml file. I have to display the text in two lines. The text "(at Dharmapuri museum)." is missing in the html file. Please tell me how to provide carriage returns while displaying the text in html from xml files?XML file:<?xml version="1.0" encoding="utf-8"?><imageData state_code="tn" site_name="kuruvinayanapalli" period="3"><row><imgName>tn_0382_3_ia_kuruvinayanapalli_antiq1_01.jpg</imgName><imgCaption>Kuruvinayanapalli: Iron Implements</imgCaption><imgDesc>Courtesy: TSDA <br /> (at Dharmapuri museum).</imgDesc></row></imageData>Displaying xml data in html file using javascript sdesc = nxmlDoc.getElementsByTagName("imgDesc");document.getElementById("idesc").childNodes[0].nodeValue = sdesc[slno].childNodes[0].nodeValue;
Link to comment
Share on other sites

Hi allIf I use document.getElementById("idesc").innerHTML = sdesc[slno].childNodes[0].nodeValue;instead of document.getElementById("idesc").childNodes[0].nodeValue = sdesc[slno].childNodes[0].nodeValue;The html tags <br/>, <i> and so on are getting affected.--Iswaria

HiWhen I use the following statementdocument.getElementById("idesc").childNodes[0].nodeValue = sdesc[slno].childNodes[0].nodeValue;The result is Courtesy: TSDA <br /> (at Dharmapuri museum).The text "<br/>" is also displayed instead of coming in a new line.The result should be as follows:Courtesy: TSDA (at Dharmapuri museum).ThanksIswaria
Link to comment
Share on other sites

Return the XML to what you initially had

<imgDesc>Courtesy: TSDA <br /> (at Dharmapuri museum).</imgDesc>

The variant Reg Edit suggested is equivalent to writing

<imgDesc>Courtesy: TSDA <br /> (at Dharmapuri museum).</imgDesc>

Which could be turned into the other, but still, it's not the same.If it doesn't work with that latest JS of yours, the situation might get a bit harder. You'd need to clone all child nodes of the <imgDesc/> element somehow.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...