Search code examples
vb6

how to assign XML values to string in Vb6


I want to assign below mentioned xml values to a string like this

Dim test As String

test = ... ?

Where the XML should contain:

      <RptVer>1</RptVer>

      <RptTyp>1</RptTyp>

    </RptInfo>

</InstRptRoot>

How can I do this and also preserve the formatting (ie linebreaks, spacing, etc.)?


Solution

  • Mark answered your question, I'll answer your second question:

    Dim test As String
    
    test = "<RptInfo>" & vbCrLf & vbCrLf & _
           vbTab & "<RptVer>1</RptVer>" & vbCrLf & vbCrLf & _
           vbTab & "<RptTyp>1</RptTyp> & vbCrLf & vbCrLf & _
          "</RptInfo>"
    

    Assuming you want it double-spaced and indented. You had also missed the leading tag, but MarkL caught that as well.