Click here to Skip to main content
14,386,278 members
Rate this:
Please Sign up or sign in to vote.
See more:
i have an xml file and loaded it using

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

  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 23:54pm
v2
Comments
koolprasadd 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
satishmachineni 19-Dec-11 6:37am
   
no while uploading some error, but actually its opening in IE,when trying to load by the above code its not coming
Timberbird 19-Dec-11 6:56am
   
Could you upload your file somewhere or add it to your question for investigation? Looks like formatting gets broken when you post it in the comments
Dylan Morley 19-Dec-11 4:54am
   
Can you open the XML document in Internet Explorer \ XML notepad? Is it definitely valid XML?
satishmachineni 19-Dec-11 5:22am
   
ya i can open the xml in internet explorer its working well, snapshot of it is

- <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

- <item>
- <title>
- <![CDATA[ Growth sectors lead Wall Street higher
]]>
</title>
- <description>
- <![CDATA[ US stocks rose on Friday with growth-related shares leading the way as investors focused on a brighter US economic outlook.
]]>

<link>http://www.business-standard.com/india/news/growth-sectors-lead-wall-street-higher/153139/on</link>
<pubDate>Fri, 16 Dec 2011 21:24:36 +0530</pubDate>
<guid ispermalink="true">http://www.business-standard.com/india/news/growth-sectors-lead-wall-street-higher/153139/on

- <item>
- <title>
- <![CDATA[ Sebi working on exit policy for bourses
]]>
</title>
- <description>
- <![CDATA[ Market regulator the Securities and Exchange Board of India (Sebi) is working on a number of new regulations for the stock exchanges, including a business-exit policy and moving the Investor Protection Funds of all bourses to a single agency.
]]>

<link>http://www.business-standard.com/india/news/sebi-workingexit-policy-for-bourses/153135/on</link>
<pubDate>Fri, 16 Dec 2011 20:52:43 +0530</pubDate>
<guid ispermalink="true">http://www.business-standard.com/india/news/sebi-workingexit-policy-for-bourses/153135/on
Sergey Alexandrovich Kryukov 19-Dec-11 10:59am
   
This is not XML! Can you post XML which failed to parse?
--SA

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100