Reputation: 437
I have a short question for you: Is there a way to use variables when adding or creating a new XElement node? I'm doing it the way described in this MSDN article.
Here's my code:
Root.<svg:g>.First().Add(<text x="Knoten.@x" y="Knoten.@y" contenteditable="true">AktZiffernfolge</text>)
However, this just creates some static text. Knoten.@x, Knoten.@y and AktZiffernfolge should be replaced by their values instead. Is there a way to do this?
Upvotes: 1
Views: 1180
Reputation: 101142
You can embed expressions with <%= exp %>
.
See How to: Embed Expressions in XML Literals (Visual Basic).
Example:
Dim Root = <root>
<g></g>
</root>
Dim AktZiffernfolge = "1233/23AB"
Dim Knoten = <Knoten x="123" y="567"></Knoten>
Root.<g>.First().Add(<text x=<%= Knoten.@x %> y=<%= Knoten.@y %> contenteditable="true"><%= AktZiffernfolge %></text>)
Root
is now:
<root>
<g>
<text x="123" y="567" contenteditable="true">1233/23AB</text>
</g>
</root>
Upvotes: 2