1

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.

4

2 回答 2

2

所以,作为一种猜测,我尝试使用 <%= 标签,它似乎有效:

Dim v as string = "Blah"
Dim x As XElement = _
    <parent>
        <child><%= v %></child>                    
    </parent>
于 2009-07-16T21:03:24.417 回答
0

System.Xml.Linq 命名空间非常灵活,所以是的,您可以采用一种方法

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

Output is <test><test2></test2></test>
于 2009-07-16T20:59:54.893 回答