XDocument Reading XML file with Root element having namespaces

后端 未结 4 1015
故里飘歌
故里飘歌 2021-01-07 06:13

I am having some trouble parsing an XML file with the root node having multiple namespaces. I want to get a list of nodes \'object\' with type string containing \'UserContro

4条回答
  •  终归单人心
    2021-01-07 06:22

    When you call Decendants with a XName parameter the XName'sNameSpace (which happened to be empty) is actually incorporated into the Name in addition to LocalName. So you can query just byLocalName

    p.Descendants().Where(p=>p.Name.LocalName == "object")
    

提交回复
热议问题