• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1667
  • Last Modified:

How to parse an XML data island with Firefox or is there a better way?

I'm trying to get some guidance on how to best parse an "XML data island" with Firefox. Please see this link in Google Groups for the essence of my question:

http://groups.google.com/group/Google-Maps-API/browse_frm/thread/86dd6810a9659589

Here is a link to my web page with the Firefox problem:

http://www.mortgagedataweb.com/googlemaps/VBScriptForXML_V5.ASP

Please note the above URL works fine with IE.

I am a rookie with regards to XML and the DOM and also with bending SQL server output into XML. I am wondering if a better way to do this would be for my server side code to actually write the XML to the file system of the web server - perhaps using the SessionID as a unique filename - and then passing this filename of the XML to the client side code so that methods such as below might be used (i.e. no browser differences):
         var request = GXmlHttp.create();
         request.open("GET", "uniquefilename.XML", true);

Please give me some guidance about how to best approach this problem. Thanks!
0
jjamjatra
Asked:
jjamjatra
  • 3
  • 3
  • 2
1 Solution
 
rdcproCommented:
If you're using SQL Server to embed the XML data island, it might be better to have the browser make a separate request for the XML, and use SQL Server's built in XML support.  This is quite well documented in the SQL Server books online, as well as in the SQL XML 3.0 download help document.  

Both IE and Firefox support an XML HTTP request object that can make separate requests for data (separate from the page request, that is).  My web site is down at the moment, or I'd be able to provide a suitable link.  Your example above, with

         var request = GXmlHttp.create();
         request.open("GET", "uniquefilename.XML", true);

is a great start.  The key is to set up a SQL XML virtual directory that provides the XML as a streamed response.  Download SQL XML 3.0, install it (doesn't have to be on a SQL Server box) and then open the help file from Start > Programs > SQLXML 3.0.  Then look up the help topics under:

- IIS Virtual Directory Management for SQL Server
- Accessing SQL Server Using HTTP
     and  
- Retrieving XML Documents by Using FOR XML on the Client Side.

Once you decouple the XML from the client like this, you can do pretty much anything you want.  There's lots of cross browser XML examples that use this, and as far as the client goes, this is what Ajax is all about.

Regards,
Mike Sharp
0
 
jjamjatraAuthor Commented:
Thank you very much for your suggestions. I have started reading the SQLXML 3.0 documentation. There are a lot of new concepts to consider.

Would you please help me focus in on some things by clarifying some things?

1. First, I do want to begin with my data on SQL Server 2000, but as I read you 1st sentence above, I should abandon the XML data island technique. Please clarify that. My original question pointed out that XML data islands are not supported except by IE and even there only on Windows platforms.

2. My original question has a link to my thread in Google Groups where I posted my server side code. You can see how I am already using FOR XML AUTO.

3. Please note -  your comments starting with "Your example above, with

         var request = GXmlHttp.create();
         request.open("GET", "uniquefilename.XML", true);

is a great start."

I am NOT using that technique currently (those are just comments); I am using the XML data island technique which does NOT work in Firefox / Mozilla.

How do I get the SERVER side (either my database SQL query or the middle tier IIS machine) to create the XML file with the unique filename? Could you possibly help me cut through this vast documentation. I have setup a virtual directory after installing SQLXML 3.0 SP2. There are lots of properties that make no sense to me. In short, I think all I want to start with is how to create an XML file somewhere so my Javascript can read it....

Once that is created, I have plenty of rich examples of parsing the XML with DOM methods.
0
 
rdcproCommented:
Answers inline:

1. First, I do want to begin with my data on SQL Server 2000, but as I read you 1st sentence above, I should abandon the XML data island technique. Please clarify that. My original question pointed out that XML data islands are not supported except by IE and even there only on Windows platforms.

<Mike> Right.  So don't use them. </Mike>

2. My original question has a link to my thread in Google Groups where I posted my server side code. You can see how I am already using FOR XML AUTO.

<Mike> Right, but you're missing out on the HTTP capabilities of SQL Server by trying to generate an XML document, then save it into the filesystem, just so you can read it out with IIS.   Go directly from SQL Server though the sqlxml.dll (which is an ISAPI filter), to the client.  Writing to the filesystem is a waste of time and resources, and doesn't buy you anything. </Mike>

3. Please note -  your comments starting with "Your example above, with

         var request = GXmlHttp.create();
         request.open("GET", "uniquefilename.XML", true);

is a great start."

I am NOT using that technique currently (those are just comments); I am using the XML data island technique which does NOT work in Firefox / Mozilla.

<Mike>
    You *should* be using it, but not to request a uniquely named XML file (unless there's some other reason to persist the XML on the filesystem...can't think of one, since the data is already in SQL Server but...).  The cross-browser ways of getting XML into the client use an approach similar to that.  I have a page on this:

        http://rdcpro.com/Members/rdcpro/snippets/crossbrowserxml/

    Note that there are other (and probably better) cross-browser approaches (and some of the frameworks are pretty good), but they all depend on the XMLHTTPRequest, or the Mozilla/Firefox equivalent.
</Mike>

How do I get the SERVER side (either my database SQL query or the middle tier IIS machine) to create the XML file with the unique filename?

<Mike>
    No, don't use the server to create a file, use the server to create an XML document in a stream, and send the stream straight to the client.
</Mike>


Could you possibly help me cut through this vast documentation. I have setup a virtual directory after installing SQLXML 3.0 SP2. There are lots of properties that make no sense to me. In short, I think all I want to start with is how to create an XML file somewhere so my Javascript can read it....

<Mike>
    The problem is that you're still thinking in terms of a file...think in terms of a stream.  My comments above should clarify that, but the whole point of a SQL Server virtual directory is that from the *client's* point of view, it seems as though it's requesting a static XML document.  SQLXML provides this HTTP based mechanism so that you only have to process and handle the XML once.  

    The way it works is like this:

    Client makes HTTP request (using the XMLHTTPRequest object or something similar) of a SQLXML virtual directory like:  

    http://myserver.com/nwind/template/CustomerWithOrders.xml?custId=ALFKI

    CustomerWithOrders.xml is a SQLXML template file that either has the SQL in it, or calls a stored proc.  It looks like:

<?xml version="1.0" encoding="UTF-8"?>
<CustOrders xmlns:sql="urn:schemas-microsoft-com:xml-sql">
      <sql:header>
            <sql:param name="custId">%</sql:param>
      </sql:header>
      <sql:query>
          SELECT
               *
          FROM
              Customers
          INNER JOIN
              Orders
          ON
              Customers.CustomerId = Orders.CustomerId
          WHERE
              Customers.CustomerId like @custId
          FOR XML AUTO
      </sql:query>
</CustOrders>

    SQLXML is an ISAPI filter, so IIS recognizes the request as one handled by the sqlxml.dll, so it retrieves the template above, and passes it along with the request parameters (custId=ALFKI) to sqlxml.  

    SQLXML makes an OLE/DB request of SQL Server, constructing the SQL from the template.  The template could easily have called a sproc, instead of making the select itself.  In fact this is the usual approach.  SQLXML takes the XML stream returned by SQL Server and sends it directly to IIS, which returns it in the HTTP response to the requesting client.


    You can follow the steps in my short tutorial to create a virtual directory:

        http://rdcpro.com/news/zones/xml/sqlxml/sqlxmlvirtualdir/

    Just make sure after you get a successful test that you take away the right to put SQL on the URL!
</Mike>

Regards,
MIke Sharp
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
jjamjatraAuthor Commented:
Thanks Mike. I am making some progress and its beginning to make more sense too. Today, however, I have been unable to get to rdcpro.com.
0
 
jjamjatraAuthor Commented:
I am so happy to close this question now and award all the points to Mike Sharp at rdcpro.com !

Thank you for all your guidance and comments. I have eliminated the IE-only "data island" approach and I'm using a template query which works in all browsers now.

EE is a great value - thanks again Mike.
0
 
plqCommented:
That rdcpro link gives an authentication error ??
0
 
rdcproCommented:
Sorry, I've moved that site to a new server, and haven't finished the implementation.  This is an old example though, and I'm not sure it will be republished.  The steps to create a virtual directory are also detailed somewhere on MSDN regarding SQLXML, maybe the help docs?  It's been a long time, and I can't recall if the snap-in has help or not.
Mike
0
 
plqCommented:
ok thanks
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now