Class SvgTextContent
Character data in an element: text or a CDATA section, kept apart so a save writes it back the same way.
public sealed class SvgTextContent : SvgContent
- Inheritance
-
SvgTextContent
- Inherited Members
Examples
SvgDocument document = SvgDocument.Parse(Icon);
// Elements, attributes and text are an editable tree, like XDocument's.
SvgElement body = document.FindById("body")!;
body.Attributes["fill"] = "#c33";
body.Attributes.Set("href", "#other", SvgNamespaces.XLink, "xlink");
SvgElement dot = new("circle");
dot.Attributes["cx"] = "12";
dot.Attributes["cy"] = "12";
dot.Attributes["r"] = "3";
document.Root.Children.Add(dot);
document.Root.Children.Add(new SvgComment(" added in code "));
foreach (SvgElement element in document.Root.Elements())
{
Console.WriteLine($"{element.Name}: {element.Attributes.Count} attributes");
}
Constructors
SvgTextContent(string, bool)
Initializes a new instance of the SvgTextContent class.
public SvgTextContent(string value, bool isCData = false)
Parameters
valuestringThe text, with entities already expanded.
isCDataboolWhether a save writes it as a CDATA section.
Properties
IsCData
Gets a value indicating whether a save writes the text as a CDATA section.
public bool IsCData { get; }
Property Value
Value
Gets or sets the text, with entities already expanded.
public string Value { get; set; }
Property Value
Methods
Clone()
Makes a deep copy without a parent: an element is copied with its attributes and all its content.
public override SvgContent Clone()
Returns
- SvgContent
The copy.
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.