i want extract svg element class name c# regex.
for example have this:
<path fill="none" ... class="highcharts-tracker highcharts-tracker" ... stroke-width="22" zindex="2" style=""/> and want delete every path elements highcharts-tracker class name using :
new regex(""); anybody know ?
in linq xml, pretty straightforward:
var classtoremove = "highlights-tracker"; var xml = xdocument.parse(svg); var elements = doc.descendants("path") .where(x => x.attribute("class") != null && x.attribute("class") .value.split(' ') .contains(classtoremove)); // remove elements match query elements.remove(); you should not use regular expressions try parse xml... xml handled existing apis, , regular expressions not appropriate tool.
edit: if it's malformed (which should have said start with) should try work out why it's malformed , fix before try other processing. there's no excuse xml being malformed these days... there plenty of xml apis every platform in existence.
Comments
Post a Comment