문제

인라인 XML이 있습니다

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

내가하고 싶은 것은 해당 XML로 설정된 변수를 얻는 것입니다.

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

이게 가능해? 나는 모든 것을 하나의 거대한 문자열과 연결 또는 string.format를 만들 수 있다는 것을 알고 있습니다. 그러나이 방법이 가능한지 알고 싶습니다.

도움이 되었습니까?

해결책

그래서 추측대로 <%= 태그를 사용해 보았고 효과가있는 것 같습니다.

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

다른 팁

system.xml.linq 네임 스페이스는 매우 유연하기 때문에 예, 한 가지 방법은

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

Output is <test><test2></test2></test>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top