Wrox Programmer Forums
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 11th, 2003, 09:10 AM
Authorized User
 
Join Date: Jun 2003
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to beyondforsaken Send a message via MSN to beyondforsaken
Default whole database to XML doc

what i have here is one entry turned to xml i don't want that i want to turn all the entries to a XML document.Can anyone help?:D



'Creates document outline
        Const strFileName As String = "c:/Beyonder/XMLExample.xml"
        Dim objXmlTW As XmlTextWriter = New XmlTextWriter(strFileName, Encoding.UTF8)

        'Sets the indentation for the XML file
        objXmlTW.Formatting = Formatting.Indented
        objXmlTW.Indentation = 4


        'Write root element
        objXmlTW.WriteStartElement("document")
        objXmlTW.WriteElementString("Name", editName.Text)
        objXmlTW.WriteElementString("Address", editAddress.Text)
        objXmlTW.WriteElementString("Telephone", editTelephone_Number.text)
        objXmlTW.WriteFullEndElement()


        'Write to the file and close
        objXmlTW.Flush()
        objXmlTW.Close()

        TextBox1.Text = TextBox1.Text + ReadDocument(strFileName)
 
Old June 11th, 2003, 10:58 AM
Authorized User
 
Join Date: Jun 2003
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

dim rs
rs.open select * from table, connobject
if not rs.eof then
 objxmltw.writestartelement("document")
 while not rs.eof
   for each field in rs.fields
       objxmltw.writeelementstring(field.name,field.value )
   next
  rs.movenext
  wend
rs.close
 
Old June 11th, 2003, 11:04 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,101
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Where is your loop?


Hal Levy
Daddyshome, LLC
 
Old June 11th, 2003, 07:54 PM
Authorized User
 
Join Date: Jun 2003
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to beyondforsaken Send a message via MSN to beyondforsaken
Default

sorry but which is coding which is code? my file name is hotel.mdb,what is connoobject? can u explain in detail?thanks..



Quote:
quote:Originally posted by Jstmehr4u3
 dim rs
rs.open select * from table, connobject
if not rs.eof then
 objxmltw.writestartelement("document")
 while not rs.eof
   for each field in rs.fields
       objxmltw.writeelementstring(field.name,field.value )
   next
  rs.movenext
  wend
rs.close
 
Old June 11th, 2003, 08:12 PM
Authorized User
 
Join Date: Jun 2003
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to beyondforsaken Send a message via MSN to beyondforsaken
Default

Is this correct? can anyone explain whats happening?is it correctly done?




Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        'Creates document outline
        Const strFileName As String = "c:/Beyonder/XMLExample.xml"
        Dim objXmlTW As XmlTextWriter = New XmlTextWriter(strFileName, Encoding.UTF8)

        'Sets the indentation for the XML file
        objXmlTW.Formatting = Formatting.Indented
        objXmlTW.Indentation = 4

        Dim rs
       If Not rs.eof Then
        objXmlTW.WriteStartElement("document")
       While Not rs.eof
        For Each field In rs.fields
           objXmlTW.WriteElementString(field.name, field.value)
       Next
       rs.movenext()
       End While
        End If
        rs.close()


        'Write root element
        'objXmlTW.WriteStartElement("document")
        'objXmlTW.WriteElementString("Name", editName.Text)
        'objXmlTW.WriteElementString("Address", editAddress.Text)
        'objXmlTW.WriteElementString("Telephone", editTelephone_Number.Text)
        'objXmlTW.WriteFullEndElement()


        'Write to the file and close
        'objXmlTW.Flush()
        'objXmlTW.Close()

        TextBox1.Text = TextBox1.Text + ReadDocument(strFileName)

    End Sub





Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating XML doc ; writing string(xml format) into KamalRaturi XML 5 May 28th, 2008 05:51 AM
Reading XML doc into dataset ankitd25 XML 4 April 29th, 2008 02:37 AM
Analyze XML doc using XSLT shumba XSLT 5 March 24th, 2006 05:19 PM
Help making a doc using XML topshed XML 2 January 28th, 2006 08:05 PM
Problem with For loop, iterating through XML Doc rj_mayer Classic ASP XML 2 April 6th, 2004 01:16 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.