none
save xml files separately RRS feed

  • Question

  • Good evening, I already know how to write xml files in the same file, the matter now is how I write files now separately, example: file 1, file 2, file 3 ... Can someone tell me how to please ... For each xml write do one xml separately.

    Currently I write the files like this and it works well, but I need to make xml file separately

                            Dim configuracionArchivo As New XmlWriterSettings
    
                            configuracionArchivo.Indent = True
    
    
    
                            Using escribiendoFactura As XmlWriter = XmlWriter.Create("Facturas.xml", configuracionArchivo)
                                With escribiendoFactura
    
    
                                    'Write the xml declaration
                                    .WriteStartDocument()
    
    
                                    .WriteStartElement("Facturas")
    
                                    .WriteStartElement("Factura")
    
    
                                    '.WriteStartElement("FechaCompra")
                                    '.WriteString(lblFecha.Text)
                                    '.WriteEndElement()
    
                                    'Nodos de factura
                                    .WriteStartElement("CedulaJuridica")
                                    .WriteString(txtCedulaJuridica.Text.ToString)
                                    .WriteEndElement()
    
                                    
    
    
    
                                    .WriteEndElement()
    
                                    .WriteEndDocument()
    
                                    .Flush()
                                    .Close()

    93/5000
    Currently I write the files like this and it works well, but I need to make xml file separately
    Sunday, August 2, 2020 2:15 AM

All replies

  • Hello,

    The most important details are left out, where is the data coming from you want to write? Do you have a small sample that will validate as valid XML as the data source for splitting into separate files.

    More details are best, otherwise we need to ask more questions from you to assist.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Sunday, August 2, 2020 10:05 AM
    Moderator
  • Hi dianas28,

    I make a test based on your question. 

    Here's the result of my test, and you can specify the path to create or cover XML file:

    You can refer to the following code:

        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            createXml(TextBox1.Text, TextBox2.Text)
        End Sub
        Public Sub createXml(ByVal path As String, ByVal context As String)
            Dim settings As XmlWriterSettings = New XmlWriterSettings()
            settings.Indent = True
            Dim writer As XmlWriter = XmlWriter.Create(path, settings)
            writer.WriteStartDocument()
            writer.WriteStartElement("Facturas")
            writer.WriteStartElement("Factura")
            writer.WriteElementString("CedulaJuridica", context)
            writer.WriteEndElement()
            writer.WriteEndElement()
            writer.WriteEndDocument()
            writer.Flush()
            writer.Close()
        End Sub

    Besides, if I have any misunderstanding, please provide more details about your question.

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by dianas28 Friday, August 7, 2020 3:30 AM
    • Unmarked as answer by dianas28 Friday, August 7, 2020 3:31 AM
    Tuesday, August 4, 2020 8:58 AM
    Moderator
  • Hi dianas28,

    How is the question going? Did you solve your problem? If your question has been answered then please click the "Mark as Answer" Link at the bottom of the correct post(s), so that it will help other members to find the solution quickly if they face a similar issue.

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, August 7, 2020 1:30 AM
    Moderator
  • Hi dianas28,

    I note that you unmark the answer, so please let me know if you need further assistance.

    We are waiting for your update.

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, August 12, 2020 5:42 AM
    Moderator