TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Smart Lucky
NA
555
640.6k
XML Excetption
Aug 15 2011 5:52 AM
Hi
I am using xml in this way and also reading in right but when i add CDATA and reading it giving me exception but why i don't know can any one help me...?
how can i read at a time cdata and attributes ...?
Xml file is
<Employees>
<Employee id="101A" firstname="naga" lastname="raju">
<Address>
<street>prakash nagar</street>
<area>begumpet</area>
<city>hyderabad</city>
<state>andhra pradesh</state>
</Address>
</Employee>
<Employee id="102A" firstname="ratna" lastname="raju">
<Address>
<street>srnagar</street>
<area>ameerpet</area>
<city>hyderabad</city>
<state>andhra pradesh</state>
</Address>
</Employee>
<Employee id="103A" firstname="murali" lastname="mohan">
<!--This is comments content-->
<Address>
<street>anna salai</street>
<area>t nagar</area>
<city>chennai</city>
<state>tamilnadu</state>
</Address>
<![CDATA[This is cdata content]]>
</Employee>
</Employees>
Cs File is
protected void Button1_Click(object sender, EventArgs e)
{
XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath("~/XMLFile.xml"));
//XmlNodeList node = doc.GetElementsByTagName("Books");
XmlNode node = doc.DocumentElement;
foreach (XmlNode cnode in node)
{
if (cnode.HasChildNodes)
{
foreach (XmlNode ChildNode in cnode.ChildNodes)
{
Response.Write("<br/>Child node is" + cnode.InnerText + "<br/>"+cnode.NodeType);
foreach (XmlAttribute nodeAttribute in ChildNode.Attributes) //Excetptio occured here...// Object reference not set to an instance of an object.
{
Response.Write("<br/>Attributes is" + nodeAttribute.InnerXml + "<br/>");
}
////Response.Write("<br/>Child node is"+cnode.InnerText+"<br/>");
}
if (cnode is XmlCDataSection)
{
XmlCDataSection cdatasection = cnode as XmlCDataSection;
Response.Write("<br/>CDATA" + cdatasection.InnerText + "<br/>");
}
}
//Response.Write(cnode.InnerText);
}
}
Reply
Answers (
1
)
how to connect between console application server and winform client?
How to Implement RSS Feed in Asp.Net