locked
xml tag with space RRS feed

  • Question

  • User-2132746437 posted

    I'm working on parsing an XML doc that i'm getting back and it has spaces in the tags such as 

    <value name="windows server"/>

    how can I grab that tag and get the value for it? 

    now, the XML file can't change due to its created by another tool, so we can't configure the file

    i know a space makes it an [invalid] xml file, but I have to work with it somehow

    Wednesday, December 10, 2014 9:16 AM

Answers

  • User-2132746437 posted

    I got it working, i had a moment where I went totally blank

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 10, 2014 9:39 AM

All replies

  • User1577371250 posted
    XmlDocument doc1 = new XmlDocument();
    doc1.Load(@"C:\test1.xml");
    
    string query = @"/Request/value/@name";
    XmlNode node = doc1.SelectSingleNode(query);
    string value = node.InnerText;
    Sample XML

    <Request> <value name="windows server"/> </Request>



    Wednesday, December 10, 2014 9:25 AM
  • User-2132746437 posted

    I got it working, i had a moment where I went totally blank

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 10, 2014 9:39 AM