0

I am trying to write several strings that contain the values of several dictionaries to a single XML file. What would be the best way to do this? I thought xDocument looked the best way, but i am struggling to write multiple strings to one document.

I intend to read from this XML file so it needs to be valid.

1 Answer 1

1

FOrgive me if I am not understanding your question, but can't you just add a parent element " to contain all strings?

Dim sbUser As New System.Text.StringBuilder
sbUser.AppendLine("<?xml version=""1.0""?>")
sbUser.AppendLine("<root>")
sbUser.AppendLine("<services>")
For Each item As KeyValuePair(Of Integer, Users) In dictusers
    sbUser.AppendFormat("<Name>""{0}""<SessionID>""{1}""</SessionID><UserName>{2}</UserName></Name>", item.Key, item.Value.SessionID, item.Value.UserName).AppendLine()
Next
sbUser.AppendLine("</services>")
sbUser.AppendLine("<cpus>")
  ...
sbUser.AppendLine("</cpus>")
  ...
sbUser.AppendLine("</root>")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.