Hi,
I am trying to read the below XML and trying to create multiple XML's from it based on the no of repeating nodes:
<?xml version="1.0" encoding="UTF-8" ?>
- <response status="1" xmlns="SomeNameSpace"> - <dam-schedule calculation="Wed May 28 15:32:16 CEST 2014" calculation_tz="2014-05-28 15:32:16 +0200" deliverydate="2014-05-30 00:00:00"> - <participants> - <participant id="800" name="ABC" shortname="A"> - <areas> - <area id="EN"> - <blocks bidclosingtme="Thu May 29 13:00:00 CEST 2014" currencyid="INR" portfolioname="AP" portfolioshortname="AP"> - <block bid-block-price="40.6" bid-price="50.0" bid-vol="50.0" currencyid="GBP" exgroupid="" from="2014-05-30 08:00:00 +0200" id="B0920" isparadoxicallyrejected="false" portfolioname="ACC_PA1" portfolioshortname="ACC_PA1" ref="W0528005-" reportpricedecimals="2" to="2014-05-30 20:00:00 +0200" user="ACC_TA1" vwap="40.6"> - <periodvolumes> <period periodid="9" volume="50.0" /> <period periodid="10" volume="50.0" /> <period periodid="11" volume="50.0" /> <period periodid="12" volume="50.0" /> <period periodid="13" volume="50.0" /> <period periodid="14" volume="50.0" /> <period periodid="15" volume="50.0" /> <period periodid="16" volume="50.0" /> <period periodid="17" volume="50.0" /> <period periodid="18" volume="50.0" /> <period periodid="19" volume="50.0" /> <period periodid="20" volume="50.0" /> </periodvolumes> </block> - <block bid-block-price="41.0" bid-price="45.5" currencyid="GBP" exgroupid="" from="2014-05-30 16:00:00 +0200" id="Bas0" isparadoxicallyrejected="false" portfolioname="ACC_PA1" portfolioshortname="ACC_PA1" ref="W054-" reportpricedecimals="2" to="2014-05-30 20:00:00 +0200" user="AT" vwap="40.38"> - <periodvolumes> <period periodid="17" volume="55.0" /> <period periodid="18" volume="45.0" /> <period periodid="19" volume="50.0" /> <period periodid="20" volume="40.0" /> </periodvolumes>
I am using the following code to read the XML:
While using the "inner.ReadOuterXml" I am getting the blocks with namespace attached. How can i get the blocks without namespace?stringnameSpace = null;
DateTime? deliveryDate = null;
DateTime? tradePlaceDate = null;
stringcompanyName = null;
varblocks = newList<string>();
XmlReader reader = XmlReader.Create(xmlFileName); while (reader.Read()) { if (reader.LocalName == "response" && reader.NodeType == XmlNodeType.Element) { nameSpace = reader.GetAttribute("xmlns").ToString(); Console.WriteLine("namespace", nameSpace); } if (reader.LocalName == "dam-schedule" && reader.NodeType == XmlNodeType.Element) { deliveryDate = System.Convert.ToDateTime(reader.GetAttribute("deliverydate")); tradePlaceDate = System.Convert.ToDateTime(reader.GetAttribute("calculation_tz")); Console.WriteLine("del", deliveryDate.ToString()); } if (reader.LocalName == "participant" && reader.NodeType == XmlNodeType.Element) { companyName = reader.GetAttribute("shortname"); } if (reader.LocalName == "block" && reader.NodeType == XmlNodeType.Element) { XmlReader inner = reader.ReadSubtree(; inner.Read(); blocks.Add(inner.ReadOuterXml()); inner.Close(); } }