bodoni / svg

Composer and parser for SVG
Other
299 stars 45 forks source link

Question: How do you assign the text content for a `element::Text` node? #77

Closed sunkit02 closed 7 months ago

sunkit02 commented 7 months ago

I have been exploring the library and found most things quite intuitive, but I can't seem to figure out how to assign the text content for a Text node after creating it with the following code:

use svg::node::element::Text;

let text = Text::new();

The target behavior is to generate a <text> tag containing a string that I provide through the rust program like the following:

<text>Hello, world</text>

Thank you so much for your help!

IvanUkhov commented 7 months ago

Yes, it has come up multiple times, and it is the most confusing part, unfortunately. Please take a look at this example (so node::Text should be attached as a child to node::element::Text):

https://github.com/bodoni/svg/blob/main/src/node/element/mod.rs#L436-L455

sunkit02 commented 7 months ago

Problem solved, thank you so much!