how to ignore xml namespaces?

前端 未结 3 1985
[愿得一人]
[愿得一人] 2021-01-15 09:50

I\'ve got test xml file that looks like this:


  
   ...
  

When I\'m t

3条回答
  •  心在旅途
    2021-01-15 10:42

    there's an article about xml here

    And i also stumbled accros this piece of code: (very helpfull)

    XmlDocument stripDocumentNamespace(XmlDocument oldDom)
    {
    // Remove all xmlns:* instances from the passed XmlDocument
    // to simplify our xpath expressions.
    XmlDocument newDom = new XmlDocument();
    newDom.LoadXml(System.Text.RegularExpressions.Regex.Replace(
    oldDom.OuterXml, @"(xmlns:?[^=]*=[""][^""]*[""])", "",
    System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Multiline)
    );
    return newDom;
    } 
    

    hope this could help

提交回复
热议问题