Board index » Visual Studio » Error extracting innerHTML using DHTML in an HTA page

Error extracting innerHTML using DHTML in an HTA page

Visual Studio222
I have an ASP application that returns data requested by the user in various

formats.

Currently it returns the data as an Excel file that can be displayed or

saved.

I have added the feature of returning the same data in XML format, either as

a Data Island or as a file

download.



My intention is to allow the user to save the XML data either as a file or

load it into the local SQL

Server database (at the Client side.



It has been suggested to me by Microsoft MVPs in various newsgroups that the

Data island is the preferred method of delivery.



However I am running into a problem. Most of my customers run a VB6

application written by me with a Browser Control that allows the Scripting

FileSystemObject to extract the innerHTML of the XML data and save it to

file or Database.



I am trying to do the same thing with DHTML in an HTA page, for those

customers that don't subscribe to the VB6 application, but wish to use the

ASP site. The HTA application however is generating an error that I can't

seem to solve....



Error: Object required: 'objXML'



Note: The page is completely loaded into the browser, because the code is

called from an OnClick event from a button that is the last control loaded

in the page, well after the XML Data island is created.



Below is the source code from VB6 (that works) and the HTA code that

generates an error.

The line flagged is:



strHTML = objXML.innerHTML



Can anyone tell me what the problem might be?

If the Data Island is the preferred method of delivery, how do I go about

committing it to disk or SQL

Server (at the Client site) without using VB6 code?



If I can't find an answer soon, I will resort to file download and then deal

with file-handling issues

that might make it difficult for the user and myself, such as making sure

the file is placed in a specific location that can be accessed easily for

loading into SQL Server.



--- VB6 Code that works properly on the XML data island ---

Private Sub GetXMLData() As Boolean

Dim objDoc As Object

Dim objXML As Object

Dim strHTML As String

Dim ts As Object, fs As Object



Set fs = CreateObject("Scripting.FileSystemObject")

Set ts = fs.CreateTextFile("PCardTest.xml", True)



Set objDoc = Me.PCardBrowser.document

Set objXML = objDoc.All("pcXML")



strHTML = objXML.innerHTML



ts.Write strHTML

ts.Close

End Sub



-- Script Code in HTA page that generates error --

<SCRIPT language=vbscript>

sub saveTOfile()

Dim objDoc

Dim objXML

Dim strHTML

Dim ts

Dim fs



Set fs = CreateObject("Scripting.FileSystemObject")

Set ts = fs.CreateTextFile("c:\temp\PCardTest.xml", True)



Set objXML = document.all("pcXML")



strHTML = objXML.innerHTML



ts.Write strHTML

ts.Close

end sub

</SCRIPT>



Thanks for your help......


-
 

Re:Error extracting innerHTML using DHTML in an HTA page

My apologies to the group. I discovered my mistake. Too many technologies to

learn and very little time to read all the books.



I originally started with an ASP page that returned the XML data island. I

then tried using the FileSystemObject within DHTML of the ASP page and found

that I wasn't allowed (apparently) to create that object from within an ASP

page.



Then I discovered the HTA information in MSDN, that indicates how the FSO is

allowed in an HTA and that an HTA can be created by simply changing the file

extension. Therein lies the mistake. I ASSUMED that the same XML would be

returned in the HTA as it was in the ASP page. WRONG!



By using the HTA extension, the ASP engine on the server did not process my

server-side code to return the XML, but rather returned all the code intact.

What a dumb rookie mistake.



So I guess the question then becomes, how do I go about extracting that XML

data from an ASP page in the Client browser without wrapping it in a VB

application that allows the use of the FSO. Is that even possible?



Thanks .....



"John Kotuby" <jkotuby@snet.net>wrote in message

Quote
I have an ASP application that returns data requested by the user in

various

formats.

Currently it returns the data as an Excel file that can be displayed or

saved.

I have added the feature of returning the same data in XML format, either

as

a Data Island or as a file

download.



My intention is to allow the user to save the XML data either as a file or

load it into the local SQL

Server database (at the Client side.



It has been suggested to me by Microsoft MVPs in various newsgroups that

the

Data island is the preferred method of delivery.



However I am running into a problem. Most of my customers run a VB6

application written by me with a Browser Control that allows the Scripting

FileSystemObject to extract the innerHTML of the XML data and save it to

file or Database.



I am trying to do the same thing with DHTML in an HTA page, for those

customers that don't subscribe to the VB6 application, but wish to use the

ASP site. The HTA application however is generating an error that I can't

seem to solve....



Error: Object required: 'objXML'



Note: The page is completely loaded into the browser, because the code is

called from an OnClick event from a button that is the last control loaded

in the page, well after the XML Data island is created.



Below is the source code from VB6 (that works) and the HTA code that

generates an error.

The line flagged is:



strHTML = objXML.innerHTML



Can anyone tell me what the problem might be?

If the Data Island is the preferred method of delivery, how do I go about

committing it to disk or SQL

Server (at the Client site) without using VB6 code?



If I can't find an answer soon, I will resort to file download and then

deal

with file-handling issues

that might make it difficult for the user and myself, such as making sure

the file is placed in a specific location that can be accessed easily for

loading into SQL Server.



--- VB6 Code that works properly on the XML data island ---

Private Sub GetXMLData() As Boolean

Dim objDoc As Object

Dim objXML As Object

Dim strHTML As String

Dim ts As Object, fs As Object



Set fs = CreateObject("Scripting.FileSystemObject")

Set ts = fs.CreateTextFile("PCardTest.xml", True)



Set objDoc = Me.PCardBrowser.document

Set objXML = objDoc.All("pcXML")



strHTML = objXML.innerHTML



ts.Write strHTML

ts.Close

End Sub



-- Script Code in HTA page that generates error --

<SCRIPT language=vbscript>

sub saveTOfile()

Dim objDoc

Dim objXML

Dim strHTML

Dim ts

Dim fs



Set fs = CreateObject("Scripting.FileSystemObject")

Set ts = fs.CreateTextFile("c:\temp\PCardTest.xml", True)



Set objXML = document.all("pcXML")



strHTML = objXML.innerHTML



ts.Write strHTML

ts.Close

end sub

</SCRIPT>



Thanks for your help......









-

Re:Error extracting innerHTML using DHTML in an HTA page

Use the XMLHTTP object to request the xml from the server-side asp

page.There are many examples to be found via google. Plus I wrote a dynamic

listbox demo available at

http://www.thrasherwebdesign.com/index.asp?pi" rel="nofollow" target="_blank">www.thrasherwebdesign.com/index.asp=links&hp=links.asp which

heavily utilizes this object.



Bob Barrows



John Kotuby wrote:

Quote
My apologies to the group. I discovered my mistake. Too many

technologies to learn and very little time to read all the books.



I originally started with an ASP page that returned the XML data

island. I then tried using the FileSystemObject within DHTML of the

ASP page and found that I wasn't allowed (apparently) to create that

object from within an ASP page.



Then I discovered the HTA information in MSDN, that indicates how the

FSO is allowed in an HTA and that an HTA can be created by simply

changing the file extension. Therein lies the mistake. I ASSUMED that

the same XML would be returned in the HTA as it was in the ASP page.

WRONG!



By using the HTA extension, the ASP engine on the server did not

process my server-side code to return the XML, but rather returned

all the code intact. What a dumb rookie mistake.



So I guess the question then becomes, how do I go about extracting

that XML data from an ASP page in the Client browser without wrapping

it in a VB application that allows the use of the FSO. Is that even

possible?

--

Microsoft MVP -- ASP/ASP.NET

Please reply to the newsgroup. The email account listed in my From

header is my spam trap, so I don't check it very often. You will get a

quicker response by posting to the newsgroup.





-

Re:Error extracting innerHTML using DHTML in an HTA page

Thanks for the reply Bob..



I will look at using the XMLHTTP object. The XML that currently is generated

on the Server side is the result of a rather complex FOR XML EXPLICIT SQL

Server query (residing in a Stored Procedure) that pulls data from 8

different tables. The part I am having difficulty with is how to capture the

XML that is returned to the client-side browser and send it as a parameter

to a Stored Procedure (already written using OPENXML) which shreds the

document back into the table rows and inserts/updates the data locally. I

don't have the option of making a direct remote SQL Server connection via

ports 1433/1434.



I can easily accomplish my task from within our proprietary VB program that

uses the Browser Control, but I am trying to offer similar functionality to

customers who do not use our program. The customer may want to load the data

into an Oracle Database, for example, or simply save the data to a disk file

for processing at a later time. Does the XMLHTTP object offer the user a

client-side interface to allow passing that XML data to whatever custom

program they may have written at their site? This may be a simple thing for

more experienced Web programmers, but at the moment I don't quite "get it".



"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom>wrote in message

Quote
Use the XMLHTTP object to request the xml from the server-side asp

page.There are many examples to be found via google. Plus I wrote a

dynamic

listbox demo available at

http://www.thrasherwebdesign.com/index.asp?pi" rel="nofollow" target="_blank">www.thrasherwebdesign.com/index.asp=links&hp=links.asp which

heavily utilizes this object.



Bob Barrows



John Kotuby wrote:

>My apologies to the group. I discovered my mistake. Too many

>technologies to learn and very little time to read all the books.

>

>I originally started with an ASP page that returned the XML data

>island. I then tried using the FileSystemObject within DHTML of the

>ASP page and found that I wasn't allowed (apparently) to create that

>object from within an ASP page.

>

>Then I discovered the HTA information in MSDN, that indicates how the

>FSO is allowed in an HTA and that an HTA can be created by simply

>changing the file extension. Therein lies the mistake. I ASSUMED that

>the same XML would be returned in the HTA as it was in the ASP page.

>WRONG!

>

>By using the HTA extension, the ASP engine on the server did not

>process my server-side code to return the XML, but rather returned

>all the code intact. What a dumb rookie mistake.

>

>So I guess the question then becomes, how do I go about extracting

>that XML data from an ASP page in the Client browser without wrapping

>it in a VB application that allows the use of the FSO. Is that even

>possible?

--

Microsoft MVP -- ASP/ASP.NET

Please reply to the newsgroup. The email account listed in my From

header is my spam trap, so I don't check it very often. You will get a

quicker response by posting to the newsgroup.









-

Re:Error extracting innerHTML using DHTML in an HTA page

John Kotuby wrote:

Quote
Thanks for the reply Bob..



I will look at using the XMLHTTP object. The XML that currently is

generated on the Server side is the result of a rather complex FOR

XML EXPLICIT SQL Server query (residing in a Stored Procedure) that

pulls data from 8 different tables. The part I am having difficulty

with is how to capture the XML that is returned to the client-side

browser and send it as a parameter to a Stored Procedure (already

written using OPENXML) which shreds the document back into the table

rows and inserts/updates the data locally. I don't have the option of

making a direct remote SQL Server connection via ports 1433/1434.



I can easily accomplish my task from within our proprietary VB

program that uses the Browser Control, but I am trying to offer

similar functionality to customers who do not use our program. The

customer may want to load the data into an Oracle Database, for

example, or simply save the data to a disk file for processing at a

later time. Does the XMLHTTP object offer the user a client-side

interface to allow passing that XML data to whatever custom program

they may have written at their site?



No. You have to create the xml document.



You can use a data-bound xml data island. Look for "data binding" at

msdn.microsoft.com/library



Bob Barrows

--

Microsoft MVP -- ASP/ASP.NET

Please reply to the newsgroup. The email account listed in my From

header is my spam trap, so I don't check it very often. You will get a

quicker response by posting to the newsgroup.





-

Re:Error extracting innerHTML using DHTML in an HTA page

Thanks Bob... Have a great day



"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom>wrote in message

Quote
John Kotuby wrote:

>Thanks for the reply Bob..

>

>I will look at using the XMLHTTP object. The XML that currently is

>generated on the Server side is the result of a rather complex FOR

>XML EXPLICIT SQL Server query (residing in a Stored Procedure) that

>pulls data from 8 different tables. The part I am having difficulty

>with is how to capture the XML that is returned to the client-side

>browser and send it as a parameter to a Stored Procedure (already

>written using OPENXML) which shreds the document back into the table

>rows and inserts/updates the data locally. I don't have the option of

>making a direct remote SQL Server connection via ports 1433/1434.

>

>I can easily accomplish my task from within our proprietary VB

>program that uses the Browser Control, but I am trying to offer

>similar functionality to customers who do not use our program. The

>customer may want to load the data into an Oracle Database, for

>example, or simply save the data to a disk file for processing at a

>later time. Does the XMLHTTP object offer the user a client-side

>interface to allow passing that XML data to whatever custom program

>they may have written at their site?



No. You have to create the xml document.



You can use a data-bound xml data island. Look for "data binding" at

msdn.microsoft.com/library



Bob Barrows

--

Microsoft MVP -- ASP/ASP.NET

Please reply to the newsgroup. The email account listed in my From

header is my spam trap, so I don't check it very often. You will get a

quicker response by posting to the newsgroup.









-

Re:Error extracting innerHTML using DHTML in an HTA page

Quote
...

By using the HTA extension, the ASP engine on the server did not

process my server-side code to return the XML, but rather returned

all the code intact. What a dumb rookie mistake.

...



The HTAs I deploy follow a hybrid deployment model. The HTA itself is simply

a wrapper for a trusted iframe hosting an ASP page. (You could also use a

single frame frameset instead of an iframe.) The iframe page doesn't have to

be asp. It could be ordinary htm, php, etc., whatever the server supports.



With this model, it doesn't matter if the user saves/runs a local copy of

the HTA - the real content is delivered via http from a web server. To test

changes to the ASP content, I keep a local copy of the HTA with the base

href URL pointing to a development web server instead of the production

server.



You can use the same model for a network file server deployment as well.

Just change the base href to "\\YourFileServer" and iframe src to

"\YourShare\YourPath\YourPage.htm".



<html>

<head><title>YourTitle</title>

<base href="http://YourProductionServer">

<hta:application id="YourAppId"

applicationName="YourAppName"

singleInstance="yes"

showInTaskbar="yes"

borderStyle="fixed"

/>

</head>

<body scroll="no" style="margin:0px">

<iframe width="100%" height="100%"

frameborder="no" border="0"

marginheight="0" marginwidth="0"

application="yes"

src="/YourSite/YourPath/YourPage.asp"

Quote
</iframe>

</body>

</html>



--

Michael Harris

Microsoft.MVP.Scripting

Sammamish WA US



-

Re:Error extracting innerHTML using DHTML in an HTA page

Thanks for the insight Michael.

Your method looks promising for my current application and probably others

to follow.



"Michael Harris (MVP)" <mikhar at mvps dot org>wrote in message

Quote
>...

>By using the HTA extension, the ASP engine on the server did not

>process my server-side code to return the XML, but rather returned

>all the code intact. What a dumb rookie mistake.

>...



The HTAs I deploy follow a hybrid deployment model. The HTA itself is

simply

a wrapper for a trusted iframe hosting an ASP page. (You could also use a

single frame frameset instead of an iframe.) The iframe page doesn't have

to

be asp. It could be ordinary htm, php, etc., whatever the server

supports.



With this model, it doesn't matter if the user saves/runs a local copy of

the HTA - the real content is delivered via http from a web server. To

test

changes to the ASP content, I keep a local copy of the HTA with the base

href URL pointing to a development web server instead of the production

server.



You can use the same model for a network file server deployment as well.

Just change the base href to "\\YourFileServer" and iframe src to

"\YourShare\YourPath\YourPage.htm".



<html>

<head><title>YourTitle</title>

<base href="http://YourProductionServer">

<hta:application id="YourAppId"

applicationName="YourAppName"

singleInstance="yes"

showInTaskbar="yes"

borderStyle="fixed"

/>

</head>

<body scroll="no" style="margin:0px">

<iframe width="100%" height="100%"

frameborder="no" border="0"

marginheight="0" marginwidth="0"

application="yes"

src="/YourSite/YourPath/YourPage.asp"

></iframe>

</body>

</html>



--

Michael Harris

Microsoft.MVP.Scripting

Sammamish WA US







-