Text from XMLFile RRS feed

  • Question

  • I'm hugely stuck and I have no idea why. I am reading in an XML file, and I just want to get the text from it. I've read a bunch of forums answers but none seem to quite do it.

    What I am doing is reading an SVG XML file and then injecting it into HTML.  I can load the XML into an XMLDoc, but can't figure out for the life of me two things.

    First, I have no idea how to iterate the document.  My expectation was that iterating the nodes recursively would actually yield values:

                foreach (var node in xmlDoc.ChildNodes)
                    foreach (Attribute a in node.Attributes)

    But the node and a lists have no properties (though there is a count).  So that seemed busted.  This would really be the best model, but I need to compare values and make edits. 

    I also tried just reading the doc into a string, but a whole bunch of carriage returns and stuff get in there (\n \r) and they just won't get removed. i.e.

    finalResult = finalResult.Replace(@"\n", "");

    And yet the \n are still there?  I read where this appeared to just be a debugger issue, and it may be.  I tried to write script to show the markup but I cannot seem to get it in a format suitable for debugging the HTM itself.  I've also tried



    But that reduces it entirely to text as does:


    Any help is super appreciated.  To recap, I want to be able to merge XML into HTML and then be able to debug the result.

    Friday, August 9, 2013 9:36 PM


  • Take a look at the Windows Runtime XML data API sample (Windows 8) for examples of several ways to work with XML files.

    If you still need help after looking at that can you provide more information on exactly what you are trying to do? Are you trying to modify the file? Just read it in as text? etc.

    It may help if you can provide minimal examples of input and expected output.


    Friday, August 9, 2013 10:18 PM