0

I have the classic XmlTextReader problem where I need to process the tag as a whole as well as child within it. So what I did was this:

AllRD = New XmlTextReader(New StringReader(XMLString.Trim())) ' an entire file
Do While AllRD.Read()
   ... loop until I find the tag I'm interested in ...
   CellXML = AllRD.ReadOuterXml()
   CellRD = New XmlTextReader(New StringReader(CellXML.Trim()))
   Do While CellRD.Read()
      ... stuff ...

This lets me parse the inner XML with Read and still access the entire tag when I get to the bottom of the loop. So now I feed it this string:

<c r="A1" s="2" t="s"><v>0</v></c>

and when I examine CellXML I get this:

<c r="A1" s="2" t="s" xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><v>0</v></c>

Anyone know how to make that new xmlns go away?

Maury Markowitz
  • 9,082
  • 11
  • 46
  • 98

1 Answers1

0

Well after a lot more Googling I returned back to SO to find the solution:

How to remove xmlns attribute with .NET XML API

The trick is to do:

AllRD = New XmlTextReader(New StringReader(XMLString.Trim()))
AllRD.Namespace = false

Not entirely obvious, and frankly, this should be default behavior IMHO.

Community
  • 1
  • 1
Maury Markowitz
  • 9,082
  • 11
  • 46
  • 98