...

View Full Version : Dynamic XML Document



mosidiot
12-14-2010, 05:31 PM
Hi,

I am trying to create a xml document and load it into a 3rd party function as follows:


var doc = new ActiveXObject('Microsoft.XMLDOM'); // OR
var doc = document.implementation.createDocument('', 'xml', null);

o.overlayKML('somefile.xml');
// Works perfectly
o.overlayKML(doc);
// Doesn't work at all, return unsupport error

I get to know that the overlayKML (3rd party function) needs to read a physical file with a path and sadly it doesn't support DOM.

How can I create a javascript document that mimic a physical file and introduce it into the function?

Thanks!

Old Pedant
12-14-2010, 08:20 PM
Rewrite the third party code to accept a string??

I don't see how you can "fool" it to accept a pseud-file any other way. It shouldn't be that hard to rewrite the third party code, if it's written in JavaScript.

rnd me
12-15-2010, 01:28 AM
if the function accepts urls, try a data: url.

mosidiot
12-15-2010, 03:51 AM
Thanks for the reply.

Ok, how about this way, let say I am creating an ActiveX file object, storing the dynamic content into the xml


var fso = new ActiveXObject("Scripting.FileSystemObject");
var s = fso.CreateTextFile("C:\\somefile.xml", true);
s.WriteLine('<--- xml content --->');
s.Close();

o.overlayKML('C:\\somefile.xml');
This way works only in IE with low browser security

But I don't want to use ActiveX because of compatibility and security issue, is there any workflow like the following:


var fo = new FileObject;
fo.content = '<--- xml content --->';

o.overlayKML(o);

I am unable to rewrite the 3rd party javascript because it's calling from their side, the script src is linked to their url.

Thanks again.

Old Pedant
12-15-2010, 08:41 AM
Did you try RndMe's suggestion? It's a long shot, but it just might work.

mosidiot
12-16-2010, 03:18 AM
Yup, using data uri with base64, but unfortunately that can't work too.

Ok, I had check their javascript already:


if (url.indexOf('160.96.187.80')>0){url=host+"api/Services.svc/overlayKML?path=" + url}
// url is the address of my xml

They need a concrete url path in their query string to get the file and process it, guess I have to contact them for the flexibility instead.

Thanks a lot guys! Learnt a lot things here!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum