Question

so i have some inline XML

Dim x As XElement = _
    <parent>
        <child></child>                    
    </parent>

what I want to do is get some variables that have been set into that xml

Dim v as string = "Blah"
Dim x As XElement = _
    <parent>
        <child>{v}</child>                    
    </parent>

Is this possible? I am aware that I could make the whole thing one giant string and concatenate, or string.format. But I want to know if this method is possible.

Was it helpful?

Solution

so, just as a guess, i tried using a <%= tag and it seems to have worked:

Dim v as string = "Blah"
Dim x As XElement = _
    <parent>
        <child><%= v %></child>                    
    </parent>

OTHER TIPS

The System.Xml.Linq namespace is very flexable, so yes you can one way would be

Dim x As XElement = <test><One></One></test>
    x.FirstNode.ReplaceWith(<test2></test2>)

Output is <test><test2></test2></test>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top