How to generate dynamic XML from aspx page

Dear Friends, 
I was using the below code in ASP to dynamically generate XML from a SQL Query
Does anyone knows how can I migrate this code to VB and ASPX?

Regards 
Robson Machado

Response.ContentType = "text/xml"
Response.Write "<?xml version='1.0' ?>" 
dim RS, CN
set CN = server.CreateObject("adodb.connection")
set RS = server.CreateObject("adodb.recordset")
CN.ConnectionString = strConnect
CN.Open
RS.Open SQLStmt,cn
Response.Write "<ROOT>"
Response.Write RS2XML(RS,"RESULT")         
Response.Write "</ROOT>"
CN.close
set rs = nothing
set cn = nothing
function RS2XML(rs, ChildNode)
 dim Field
 if rs is nothing then exit function
 ChildNode = ucase(ChildNode)
 if rs.eof then 
  RS2XML = ""
  exit function
 end if  
 do until rs.eof
  if ChildNode <> "" then RS2XML = RS2XML & "<" & ChildNode & ">"
  for each field in rs.fields
   RS2XML = RS2XML & " <" & ucase(field.name) &  ">" & 
server.HTMLEncode(NotNull(field.value)) &  "</" & ucase(field.name) & ">"   
			
  next
  if ChildNode <> "" then RS2XML = RS2XML & "</" & ChildNode & ">" 
  rs.movenext
 loop
end function
Function NotNull(vOrig)
 If(IsNull(vOrig)) then 
  NotNull = ""
 else
  NotNull = vOrig
 end if
End Function
0
8/24/2004 2:03:02 AM
dotnet.xml 7266 articles. 0 followers. Follow

1 Replies
543 Views

Similar Articles

[PageSpeed] 50

Robson,
Just add the "x" to "asp", .Net Framework can run it.
Hope it helps

Eduardo 
"Robson Carvalho Machado" <RobsonCarvalhoMachado@discussions.microsoft.com> wrote in message news:<00BB018E-4FA5-4386-86A2-95F4556C857F@microsoft.com>...
> Dear Friends, 
> I was using the below code in ASP to dynamically generate XML from a SQL Query
> Does anyone knows how can I migrate this code to VB and ASPX?
> 
> Regards 
> Robson Machado
> 
> Response.ContentType = "text/xml"
> Response.Write "<?xml version='1.0' ?>" 
> dim RS, CN
> set CN = server.CreateObject("adodb.connection")
> set RS = server.CreateObject("adodb.recordset")
> CN.ConnectionString = strConnect
> CN.Open
> RS.Open SQLStmt,cn
> Response.Write "<ROOT>"
> Response.Write RS2XML(RS,"RESULT")         
> Response.Write "</ROOT>"
> CN.close
> set rs = nothing
> set cn = nothing
> function RS2XML(rs, ChildNode)
>  dim Field
>  if rs is nothing then exit function
>  ChildNode = ucase(ChildNode)
>  if rs.eof then 
>   RS2XML = ""
>   exit function
>  end if  
>  do until rs.eof
>   if ChildNode <> "" then RS2XML = RS2XML & "<" & ChildNode & ">"
>   for each field in rs.fields
>    RS2XML = RS2XML & " <" & ucase(field.name) &  ">" & 
> server.HTMLEncode(NotNull(field.value)) &  "</" & ucase(field.name) & ">"   
> 			
>   next
>   if ChildNode <> "" then RS2XML = RS2XML & "</" & ChildNode & ">" 
>   rs.movenext
>  loop
> end function
> Function NotNull(vOrig)
>  If(IsNull(vOrig)) then 
>   NotNull = ""
>  else
>   NotNull = vOrig
>  end if
> End Function
0
edumen26 (2)
8/24/2004 9:04:40 PM
Reply:

Similar Artilces:

GENERATE a TEXT FILE Using INPUT from a Form ??
I need to generate a Text file using (partly) information entered by the user on a form. I already have the TEMPLATE for the text file......I need to generate a COPY of the file with the word entered by the user into the form INSERTED into the text file. The text file is actually code for a web page (will have an .htm extension). The file is simply an exact copy of an existing template with only ONE ITEM of the text changed to a word that is entered into a form by a user. Example: One line within the template file is: "We have several of these items available in BLUE." I have...

linked subforms on same Tab page
I linked 2 subforms on a Tab page - they work, but a Parameter box pops asking for the Child link field - Forms![MainTabtest]![PgmList].Form.ProgramID. First subform is continous row form, with onCurrent event set to requery linked Child form to the above selected row. Once I say ok to parameter box, the correct data shows based on row selected in Parent form. any idea why the parameter box and how to eliminate? thx! ...

embed x.s sheet to HTmL page
Hi, I have a file called Bonds.xls located on my C drive in a flode called Support. I want to insert this file to a HTML pae. I trie embed, object and everything I could find but i cant get it to insert I am using office and OS wkin200. Can anybody give me some help? I dont know if I am using tags wrong o just wrong tags. thank -- Message posted from http://www.ExcelForum.com Have you tried saving the worksheet in html format? You can incorporate this html code into the web page. - Jon ------- Jon Peltier, Microsoft Excel MVP http://www.geocities.com/jonpeltier/Excel/index.html _______ ...

Write a tool to generate a PST file with the same structure as old
I will migrate 1000+ users to Exchange 2010 and those users are using OL 2003 and OL2007. To help them migrate more smoothly, I will provide a tool for them to generate PST file with the same structure as an old PST file. Is it possible? How to begin this idea? Thanks, Sam Have you looked at ExMerge? If you are copying a PST file, why do you need to create a copy instead of just using the original PST file? -- Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool - "PST TOOL" <PST TOOL@discussions.microsoft....

Workflow Rule generated E-Mails
Hello: I have a Workflow Rule that sends an E-Mail every time a new Case is created which works quite well. It seems the Workflow Rule generated E-Mail by default attempts to send the E-Mil to the "Primary Contact" associated with the "Account". I do NOT want the E-Mail to be sent to the "Account", Primary Contact and would prefer not to alter the "Account", Primary Contact or E-Mail Address. How can this be accomplished? Thanks -Bill I'm assuming that you are using a template for the email. The problem with workflow is that you can e...

Macro named "Page Control"
After many successful printings I received this message when I tried to print a report; Access can't find the macro "Page Control." I never created a macro prior to printing the report many times. How do I correct this? ...

IE8 displays page cannot be displayed...
I am writing a WEB Service that is using Negotiate protocol with the MS api AcceptSecurityContext. If the browser is not logged into the domain but a group and tries to access the service the browser will respond with a WWW-Negotiate header passing a token to the service. However the browser will return a Page Cannot be displayed if the output of the AcceptSecurityContext returned a SEC_I_CONTINUE_NEEDED and the output buffer is sent back. I would have expected the browser to prompt for credentials or make a new request and choose another option when the cycle repeats. If this is...

VB.NET for Office Open XML
I have been working on a function that inserts a slide into a presentation. I am having a problem grasping the steps to add a child node to the parent document. in this case a slide to the presentation. There is code on the MSDN site but it has several errors and when I fixed them it would not update the slide title. It would actually corrupt the file. Here is what I have so far: Public Function PPTInsertNewSlide(ByVal fileName As String, ByVal position As Integer, ByVal title As String) As Boolean Dim returnValue As Boolean = False Dim documentPart As PackagePart = Noth...

Serialize objects into xml without declarations
Hi, Is it possible to serialize objects in XML without the declaration <?xml version="1.0"?> in the the result of the serialization. I want to insert this result into antoher XML stream. Thanks Monorom ...

Dynamic Range broken
I've been using a spreadsheet with a dynamic range to do a VLOOKUP for months now. Suddenly, it's broken, and I can't figure out why. The formula is =OFFSET(ActivityList!$A$1,0,0,COUNTA(ActivityList!$A:$A),2) The sheet it's on is named "Activity List" on the tab and in the "Properties" list. The formula in the workbook on another worksheet is: =IF(ISERROR(VLOOKUP(B1,namelist,2,FALSE)),"",VLOOKUP(B1,namelist,2,FALSE)) The dynamic range is "namelist". Any suggestions? There seems to be a mismatch between the worksheet names--one has tha...

Generating serializable class using XSD.exe
Hi Serializable classes generated from xsd files using xsd.exe always uses an array? Is there any way to force xsd.exe to use collection (ArrayList or equivalent) classes instead of Array? is there any other tool that could be used? Thanks in advance Regards Cross post ... YUCK! you couldn't possibly include any other groups, could you ... check out David Cazzulino's blog for a work around. -- HTH Christoph Schittko [MVP] Software Architect, .NET Mentor "tushar" <tav_2000@hotmail.com> wrote in message news:u7zrWrJjDHA.1960@TK2MSFTNGP12.phx.gbl... > Hi >...

Aligning Items on Back Side of Page
I do a lot of double sided printing (bookmarks,etc.) that need to line up front & back. However, it's always been hit & miss and never perfect. Please tell me if there is a way to have items match up on first & second pages in Publisher so that when I run a page through twice object will be in align. Thank you. P.S. Looking for help soon After managing to set up OE-QuoteFix on his new PC, Ed reads a message from Joy <joy_lum@usw.salvationarmy.org.NOSPAM>... > Please tell me if there is a way to have items match up on > first & second pages in Publisher s...

Cannot post batches in Dynamics
I'm trying to post batches that has a posting interrupted status in Batch recovery window in Dynamics GP, but after doing this I receive the following error: "Batch failed to complete posting. Use batch recovery to complete posting process." I've already tried to run the following queries to solve this issue: delete activity delete sy00800 delete sy00801 delete dex_lock delete dex_session I've also checked if the mkdtopst and bchsttus fields are set to 0 for batches in sy00500 table. But non of these helped. Every time I try to post a batch i receive the error: ...

Update for Microsoft XML core service 6.service pack 2
Updates are ready. Message bubble shows constantly. Updates won't load millypede wrote: > Updates are ready. Message bubble shows constantly. Updates won't > load Operating System? Service Pack level? Architecture? Anything that you have tried? -- Shenan Stanley MS-MVP -- How To Ask Questions The Smart Way http://www.catb.org/~esr/faqs/smart-questions.html ...

Array Bounds Exception Inside system.xml.dll
Array Bounds Exception inside system.xml.dll. Test data is a dozen GB (available for the asking on CD). Source code follows. Call into system.xml.dll happens at the while statement.. using System using System.Xml using System.Collections // This program reads an ASCII file of XML elements // The output is a list of unique NODE TYPEs // For example, <head> produces head in the output // There is no validation of the XML namespace xmlReaderAp /// <summary /// Summary description for Class1 /// </summary class Class /// <summary /// The main entry point for the...

Dynamics GP
Today my users mentioned that they do not like version 9.0 of GP that we recently installed. They are finding a lot of little changes to windows and utilities that seem to make it not as user-friendly as the old 7.5 version we converted from. SO, I'm wondering if anyone has had similar problems and/or know if version 10.0 is less quirky. -- DJanson I think there is a difference between the meaning of quirky and the complaints of the users. Certainly, GP 9 eliminated the palettes, one of the biggest differences. I know the Sales Transaction Entry window has a different order f...

ANN: New XML Differencing, Updated XML Mapping in Stylus Studio 5.3
A new update for the Stylus Studio XML IDE adds a new XML Differencing Tool, updated visual XML mapping tools and many other features. Download a free trial of Stylus Studio 5.3 at: http://www.stylusstudio.com/xml_download.html Highlights of new XML Differencing Tool: * Differencing of XML files and folders using a customizable color-coded XML tree view * Support for one-to-one and many-to-one XML file * Step through XML differences node-by-node * View differences using "split-screen" and "merged changes" views * Expand all changes, or collapse identical XML blocks to sim...

using Xsd.exe to generate classes *properly*
Ok, I searched the group and the net but didn't find what I was looking for. :) I have an xsd which must be in all lowercase(the tags). However, I'd like the generated classes (with xsd.exe) to be properly cased such as Person, Car, Company, MainMenu instead of person, car, company, mainmenu from tags <person>, <car>, <company>, <mainmenu>. I know that once generated I can rename the class and its memebers and use XmlElementAttribute and XmlAttributeAttribute to coerce the xml to be lowercase. Is there a way to make sure though that the generated class in th...

How can I automate a respose from an Access Page?
I am trying to set up an access page that allows the user to enter a request for a new project. How do I set up a button or function or something that will notify me when a user has placed a request? well if you were using SQL Server and Access Data Projects then you could fire XP_sendmail by using a trigger you can't do anything similiar with MDB On Jun 25, 5:12 am, Jacinda A <Jacin...@discussions.microsoft.com> wrote: > I am trying to set up an access page that allows the user to enter a request > for a new project. How do I set up a button or function or something ...

How dynamically create routing slip based on names in specific cel
The following macro creates a routing slip for two specific individuals. How can I change this to create a routing slip based on the names entered in specific spreadsheet cells? Sub Macro5() ' ' Macro5 Macro ' Macro recorded 8/8/2005 by Xavier Cougart ' Sheets("PAF Form").Copy ActiveWorkbook.HasRoutingSlip = True With ActiveWorkbook.RoutingSlip . Recipients = Array("Roger Clemens", "Joe Torry") . Subject = "Routing: Book1" . Message = "" . Delivery = x1OneAfterAnother . ReturnWhenDon...

Dynamic Dialog
I am fairly new to UI programming using VC++. I am looking for ways to modify a dialog box dynamically. In other words, I want to be able to add controls to an exisitng dialog during run time. This is a simple dialog which will be empty initially. Just before it is shown, I want to be able to add rows or columns of check boxes with static texts next to them, based on some strings read from the registry. Is this possible? How? Any code sample will be helpful. Thanks in advance Scott, Thanks very much for the quick reply. The reason I have to add them dynamically as opposed to during d...

FS: CHEAP Books
I am selling these books in a lot. I am not selling them individually. Total Number of books: 11 Total List Price Value: $476.98 Total Asking price: $50 Location: Houston, TX USA, but willing to ship via Media Mail. I take Paypal. Most of the books are in NEW or LIKE NEW condition. A small minority may have some shelfwear. There may be remainder marks. One book has a tear on the binding cover, but the binding is as tight as a drum. There is no highlighting or writing in any of the books. Please include the subject heading so that I will know which books your are interested in as I ...

Any XML Naming Conventions?
Does the use of DTD, XML Schema and similar constructs adopt the use of C# naming conventions? If so how do I make the distinction of how to apply C# conventions with XML elements, attributes and so on? Any referrals to resources that discuss or document XML Naming Conventions? -- <%= Clinton Gallagher, "Twice the Results -- Half the Cost" Architectural & e-Business Consulting -- Software Development NET csgallagher@REMOVETHISTEXTmetromilwaukee.com URL http://www.metromilwaukee.com/clintongallagher/ clintonG wrote: > Does the use of DTD, X...

Dynamic range thru inputbox
I have the folowwing code, that works perfectly ok Sub FindOrd() Dim varX As String Dim varY As String Dim FindOrd As String FindOrd = "" For Each c In Selection.Cells FindOrd = "" For Each x In Sheets(1).Range("A1:A6").Cells varX = InStr(1, c.Value, x.Value) If varX <> 0 Then varY = InStr(varX, c.Value, " ") If varY = 0 Then FindOrd = FindOrd & Mid(c.Value, varX, Len(c.Value)) &...

How do I get the text from running off a page (have it skip to th.
I need to be able to have text skip from one cell down to the next row without it running off a page (hard return) Amy Not sure what you need here. If you want text to stop at a certain point in a cell then drop down to next cell below, just hit ENTER key whenever you choose. If you want the text on more than one line in a cell, you can hit ALT + ENTER to create a CR in the cell. Or just type it all in one cell then choose Wrap Text and widen the column. Gord Dibben Excel MVP On Fri, 15 Apr 2005 14:48:03 -0700, "Amy Maestas" <Amy Maestas@discussions.microsoft.com> wro...