You need to be logged in to post in the forums. If you do not have an account, please sign up first.

Go to last post

11. September 2012, 11:48:54

sureshdavid

Posts: 10

connecting with XML

Hi, I'm trying to load an "xml" in my HTML app. But its not working in TV emulator.
I'm new to Tv app development. Please help me to solve my issue..

this is my code...
function loadXML(){
		if (window.XMLHttpRequest)
		{// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp=new XMLHttpRequest();
		}
		else
		{// code for IE6, IE5
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.open("GET","http://192.168.75.80/xml/books.xml",false);
		xmlhttp.send();
		xmlDoc=xmlhttp.responseXML;
		alert(xmlDoc.getElementsByTagName("book")[1].attributes.getNamedItem("id").nodeValue);
		alert(xmlDoc.getElementsByTagName("book")[1].getElementsByTagName("author")[0].childNodes[0].nodeValue);
		//xmlDoc=loadXMLDoc("books.xml");
		x=xmlDoc.getElementsByTagName("author");
		document.write(x[1].childNodes[0].nodeValue);
	}


Please help me..
Thanks and Regards,
Suresh J David.

12. September 2012, 10:54:43

Opera Software

lbendig

Posts: 55

Does your server you are sending querry to handles CORS?
For more information, please check: http://dev.opera.com/articles/view/dom-access-control-using-cross-origin-resource-sharing/

13. September 2012, 09:12:33

sureshdavid

Posts: 10

Originally posted by lbendig:

Does your server you are sending querry to handles CORS?
For more information, please check: http://dev.opera.com/articles/view/dom-access-control-using-cross-origin-resource-sharing/



Thanks for your reply. I have read the article.
According to my understanding we need to add "Access-Control-Allow-Origin: *" to somewhere. I didnt get properly where we need to add it either our xml file or any other configuration file which is in application server or virtual machine server?

Could you please clarify my questions?

Thanks,
Suresh J David

13. September 2012, 09:57:51

Opera Software

lbendig

Posts: 55

That's job for your web server. The web server should inform client (browser) if its host is allowed to access the web content. It means that you have to configure you web server to send an appriopriate replay.

13. September 2012, 10:00:06

Opera Software

lbendig

Posts: 55

Maybe this page will be helpful for you, there is tutorial how to enable CORS on various web servers: http://enable-cors.org/

24. September 2012, 06:21:02

sureshdavid

Posts: 10

Originally posted by lbendig:

Maybe this page will be helpful for you, there is tutorial how to enable CORS on various web servers: http://enable-cors.org/



cors is activated, and if i try the URL directly in the address bar, the XML is viewing properly in the operaTV emulator browser, But if i do the same within the application. It given no result. The issue is still open. Please help me what i've to do next.

The application run in chrome, opera, firefox browsers in local system, and perfectly run in opera browser within the emulator if i directly run the application,

but the application is not running from the "mydata" application. Please clarify me..

Thanks,

24. September 2012, 14:03:21

Opera Software

lbendig

Posts: 55

Which version of TV Emulator do you use? You can just check what is selected in web remote control settings, 'General' tab, 'TV Emulator version'.

25. September 2012, 06:07:06

sureshdavid

Posts: 10

TV Emulator version is 3.3.
Any problem on that?..

25. September 2012, 08:55:23

Opera Software

lbendig

Posts: 55

For 3.3 there should not be any problems (problems could be in 3.1 since CORS is not supported in the older version, so if you e.g. have TV Emulator 3.3 but you have selected 3.1 in web remote control setting, the CORS would not work for you - old cross-domain hecking mechanizm is used instead).
I've just tested CORS wit 3.3 version and everything works fine for me, it's difficult to tell me then what's the problem you have. Could you give more details, e.g. what is the code you use, how you set your web server, etc.?

25. September 2012, 09:00:46

Opera Software

lbendig

Posts: 55

Can you test this page in emulator? https://test-cors.appspot.com/#technical
All tests passed for me.

Forums » Dev.Opera » Opera TV Content Development Discussions