Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Dynamic XML Document

    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!

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,028
    Thanks
    75
    Thanked 4,325 Times in 4,291 Posts
    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.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,277
    Thanks
    10
    Thanked 581 Times in 562 Posts
    if the function accepts urls, try a data: url.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%

  • #4
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

    Code:
    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:

    Code:
    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.

  • #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,028
    Thanks
    75
    Thanked 4,325 Times in 4,291 Posts
    Did you try RndMe's suggestion? It's a long shot, but it just might work.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #6
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yup, using data uri with base64, but unfortunately that can't work too.

    Ok, I had check their javascript already:

    Code:
    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!


  •  

    LinkBacks (?)


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •