I am currently having a problem with reading a XML file using XPath expression. I have used the XmlDocument class. When I try reading a particular node from the XML, I get an empty list. The node which I am trying to read is the ID below ProductionRequest.
Here is the XML file which I tried to read:
<?xml version="1.0" encoding="iso-8859-1"?>
<ProductionSchedule xmlns="http://www.wbf.org/xml/b2mml-v02"> 
  <ID>00000020000000</ID>
  <Location>
   <EquipmentID>8283</EquipmentID>
   <EquipmentElementLevel>Site</EquipmentElementLevel>
  <Location>
   <EquipmentID>0</EquipmentID>
   <EquipmentElementLevel>Area</EquipmentElementLevel>
   </Location>
  </Location>
 <ProductionRequest>
    <ID>0009300000000</ID>
    <ProductProductionRuleID>W001</ProductProductionRuleID>
    <StartTime>2017-04-20T23:57:20</StartTime>
    <EndTime>2017-04-20T24:00:00</EndTime>
    </ProductionRequest>
  </ProductionSchedule>
This is the code which I used to read the above XML
using System;
using System.Xml.Linq;
using System.Xml;
using System.Xml.XPath;
namespace XML
{
  class Program
  {
    static void Main(string[] args)
    {
     Console.WriteLine("Hello World!");
     string fullName = "F:\\Programming\\XML\\Example XML.xml";
     XmlDocument xreader = new XmlDocument();
     xreader.Load(fullName);
     XmlNode root = xreader.DocumentElement;
     XmlNodeList xnList1 = 
            xreader.SelectNodes("/ProductionSchedule/ProductionRequest/ID");
    }
  }
 }
I could not find the cause for this problem. Could anyone help me in this regard. Looking forward for valuable inputs.
 
     
    
