locked
how to receive multiple xml files in a string in VB.net RRS feed

  • Question

  • User1720628292 posted

    Hi,

    Following is my code to receive a xml file as string.I want to change it by receiving multiple xml files and process it .how do i check whether the received string has multiple xml files?

    <WebMethod()> _
        Public Function read(str As String) As String
    
            XDocument.Parse(str)
    
    
            Dim ds As New DataSet
            Try
                ds.ReadXml(New StringReader(str))
            Catch ex As Exception
    
            End Try
            Call ProcessDataSet(ds)
            Return "hi"
        End Function

    Tuesday, October 14, 2014 2:12 AM

Answers

  • User61956409 posted

    Hi RamThilak,

    Thanks for your post.

    I want to change it by receiving multiple xml files and process it .how do i check whether the received string has multiple xml files?

    As for your problem, you could use some specific delimiters to separates multiple xml files as string.

    For example: use space character (“ ”) to separates strings

    Dim xmlfiles As String = "TestData0.xml TestData1.xml TestData2.xml"

    Then we could use the Split function to split strings with delimiter as below.

    Dim filesArray() As String = Split(xmlfiles)

    Finally, loop through filesArray to do some operation.

    Dim file As String = ""
    For i As Integer = 0 To filesArray.Length - 1
        file = filesArray(i).ToString()
        read(file)
    Next
    

    For more information about Split Function, please refer to the following link.

    If you have any question about my reply, please let me know freely.

    Best Regards,

    Fei Han

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, October 14, 2014 10:56 PM