Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have an xml file and loaded it using

C#
string xmlpath = @"D:\satish\satti.xml";
XmlDocument xdoc = new XmlDocument();
xdoc.LoadXml(xmlpath);
XmlNodeList nl = xdoc.GetElementsByTagName("//title");
return nl.ToString();


when iam trying to invoke the service ,it is saying
data at root element is invalid,xml is well formed,
the system trace is

C#
  erver stack trace: 
   at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
   at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
   at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.ClientReliableChannelBinder`1.RequestClientReliableChannelBinder`1.OnRequest(TRequestChannel channel, Message message, TimeSpan timeout, MaskingMode maskingMode)
   at System.ServiceModel.Channels.ClientReliableChannelBinder`1.Request(Message message, TimeSpan timeout, MaskingMode maskingMode)
   at System.ServiceModel.Channels.ClientReliableChannelBinder`1.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Security.SecuritySessionClientSettings`1.SecurityRequestSessionChannel.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at IService1.gettitle()
   at Service1Client.gettitle()
Posted
Updated 18-Dec-11 22:54pm
v2
Comments
koolprasad2003 19-Dec-11 4:52am    
can you show us XML ?
satishmachineni 19-Dec-11 5:22am    
<channel>
<item>
<title><![CDATA[Top 9 cos lose Rs 61,485 cr in m-cap, SBI worst hit]]></title>
<description><![CDATA[Weak stock markets pulled down the combined market capitalisation (m-cap) of the country's nine most-valued firms by Rs 61,485 crore last week, with SBI taking the biggest hit.]]>
<link>http://www.business-standard.com/india/news/top-9-cos-lose-rs-61485-cr-in-m-cap-sbi-worst-hit/153163/on</link>
<pubDate>Sun, 18 Dec 2011 10:33:13 +0530</pubDate>
<guid ispermalink="true">http://www.business-standard.com/india/news/top-9-cos-lose-rs-61485-cr-in-m-cap-sbi-worst-hit/153163/on

<item>
<title><![CDATA[Gold snaps 5-day losing streak, gains Rs 75]]></title>
<description><![CDATA[Snapping five-day losing streak, gold prices recovered Rs 75 to Rs 27,840 per 10 gram in the national capital today on buying at lower levels amid firm trend overseas.]]>
<link>http://www.business-standard.com/india/news/gold-snaps-5-day-losing-streak-gains-rs-75/153154/on</link>
<pubDate>Sat, 17 Dec 2011 15:38:06 +0530</pubDate>
<guid ispermalink="true">http://www.business-standard.com/india/news/gold-snaps-5-day-losing-streak-gains-rs-75/153154/on

<item>
<title><![CDATA[Weekly Report Sensex, Nifty hit 2-yr lows on growth woes]]></title>
<description><![CDATA[In the week to December 16, benchmark share indices ended at their two-year lows weighed by dismal October IIP data, weakening rupee, high headline inflation and growth concerns.]]>
<link>http://www.business-standard.com/india/news/weekly-report-sensex-nifty-hit-2-yr-lowsgrowth-woes/153144/on</link>
<pubDate>Sat, 17 Dec 2011 09:50:14 +0530</pubDate>
<guid ispermalink="true">http://www.business-standard.com/india/news/weekly-report-sensex-nifty-hit-2-yr-lowsgrowth-woes/153144/on
Timberbird 19-Dec-11 5:57am    
Is title really the first element of your xml file? If yes, then this xml doesn't actually have root element and really is malformed.
satishmachineni 19-Dec-11 6:26am    
y , can u expain
Timberbird 19-Dec-11 6:32am    
Xml needs root element, which would contain all the other elements: <?xml version="1.0"?><root>...(all the other elements here)...</root>. You can see example structure here

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900