GetXML does not output added child elements
See original GitHub issueHi,
I’m having trouble getting back the correct XML after adding sub elements to an SvgDocument
Given the following svg in a file “Min.svg”:
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ev="http://www.w3.org/2001/xml-events" xml:space="preserve">
<g transform="translate(5, 5)">
<rect width="25" height="50" />
</g>
</svg>
and the following code:
void Main()
{
var path = @"C:\Users\USERNAME\Desktop\Min.svg";
var svgDoc = SvgDocument.Open(path);
var grp = svgDoc.Children.OfType<SvgGroup>().FirstOrDefault();
if (grp != null)
{
for (int i = 1; i < 3; i++)
{
grp.Children.Add(new SvgCircle
{
CenterX = 10 * i,
CenterY = 10 * i,
Radius = 50
});
}
}
svgDoc.GetXML().Dump();
}
This (LINQPad) sample outputs the following text (without the SvgCircle elements being displayed):
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg d1p1:space="preserve" ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xml="http://www.w3.org/XML/1998/namespace" version="1.1" xmlns:d1p1="http://www.w3.org/XML/1998/namespace" xmlns="http://www.w3.org/2000/svg">
<g transform="translate(5, 5)">
<rect width="100" height="50" />
</g>
</svg>
My main question is where are the added elements?
Other questions are why does the d1p1
alias get added and, also is it correct that the xmlns:ev="http://www.w3.org/2001/xml-events"
gets picked up as a custom attribute (SvgDocument.CustomAttributes)?
Many thanks for any insight
John
NuGet version 3.2.3 .Net Framework 4.8 Windows 10 Pro 20H2 (build 19042)
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (6 by maintainers)
Top Results From Across the Web
java - Get XML only immediate children elements by name
This code would give the following output, showing only direct child elements of the initial root node. NODE num:-1 NODE num:-1.1 NODE num:- ......
Read more >Using the FOR XML Clause to Return Query Results as XML
As you can see, each column is added as a child element to the <row> element. You do not have to specify the...
Read more >10 Generating XML Data from the Database
The list of values that follow the XMLAttributes() clause are converted to XML format, and are made as children of the top-level element....
Read more >xml.etree.ElementTree — The ElementTree XML API
Selects all elements that have a child named tag whose complete text content, including descendants, does not equal the given text . New...
Read more >XML DOM - Get Node Values
Element nodes do not have a text value. The text value of an element node is stored in a child node. This node...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@hakakou
Regarding the operation of Children, I think that the change from 3.2.3 to 3.3.0 has not changed.
Please create new issue and report problem.
@H1Gdev - can you have a look please? I won’t have access to a computer for a week.