This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<item xmlns="http://libero.pub" xmlns:jats="http://jats.nlm.nih.gov" xmlns:xlink="http://www.w3.org/1999/xlink"> | |
<meta> | |
<id>demo-launch-post</id> | |
<service>scholarly-articles</service> | |
</meta> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class XmlStripper | |
{ | |
public XmlNode RemoveAllNamespaces(XmlNode documentElement) | |
{ | |
var xmlnsPattern = "\\s+xmlns\\s*(:\\w)?\\s*=\\s*\\\"(?<url>[^\\\"]*)\\\""; | |
var outerXml = documentElement.OuterXml; | |
var matchCol = Regex.Matches(outerXml, xmlnsPattern); | |
foreach (var match in matchCol) | |
outerXml = outerXml.Replace(match.ToString(), ""); |