I am a C # developer who broke into the first VB code he wrote with VB6, so if I ask a pretty obvious question, please forgive me.
I decided to experiment with XML literals to generate some XML code for me, instead of using XMLDocument
I have 2 questions, the second about a workaround due to my inability to find out the first.
1: The perfect solution
I have an ElementName element dictionary, ElementValue, whose KeyValue pairs I looped in the hope of dynamically generating values, but the following syntax is dying terribly
Dim xConnections As XElement
For Each connection As Connection In connections.AsList
For Each kvp As KeyValuePair(Of String, String) In connection.DecompiledElements
xConnections = <Connections> <<%= kvp.Key %>><%= kvp.Value %><\<%=kvp.Key %>> </Connections>
Next
Next
I vaguely recall the T4 syntax (syntax <% =%>) that can handle more complex operations (rather than directly assigning it to the object <% =) and the Response.Write object, write the output, but I cannot remember the details.
2: Cludgy workaround
Instead, I thought about creating a StringBuilder object and assigning it .ToString to XElement, but this also failed with a conversion error.
I would rather continue to use the concept of a pair of key values in the example above, since I feel that concatenating a string, as in example 2 above, is rather unpleasant, and I really should return to using XMLDocument if instead.
Any thoughts or help that are much appreciated
johnc source
share