1
Reply

XML

Smart    Lucky

Smart Lucky

Apr 6 2011 3:38 AM
1.4k
hi

i have wrote following program its not providing me acurate result which i want and it showing this ( #text)  but where it came from i dont know you can run it is running correct but no desired out put  can any one help me.....?

<?xml version="1.0" encoding="utf-8" ?>
<hidaya>
 <IT>
   <SoftwareDelevelopment>
     <ASP time="Three Month" at="Jamshoro">ASP.NET, MS SQLSEVER, ADVANCE</ASP>
     <PHP time="Four month" at="Jamshoro">Basic php advance php mysql joomla</PHP>
   </SoftwareDelevelopment>
   <NetworkAddminstrator time="One Month">
         MCSE
   </NetworkAddminstrator>
   <Linux time="One Month">Linux Addminstration</Linux>
 </IT>
</hidaya>





 using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        XmlDocument doc = new XmlDocument();
        doc.Load(Server.MapPath("XMLFile.xml"));
        foreach (XmlNode node in doc.DocumentElement)
        {
            if (node.HasChildNodes)
            {
                Response.Write("Content of" + node.Name + "   Node<br/>");
                foreach (XmlNode childNodeNodeElement in node)
                {
                    Response.Write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + childNodeNodeElement.Name+"<br/>");
                    if (childNodeNodeElement.HasChildNodes)
                    {
                        foreach (XmlNode childNodechildNodeNodeElementElement in childNodeNodeElement)
                        {
                            Response.Write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + childNodechildNodeNodeElementElement.Name+"<br/>");
                            if (childNodechildNodeNodeElementElement.NodeType==XmlNodeType.Element)//.HasChildNodes)
                            {
                                foreach (XmlNode childNodechildNodeNodeElementChileElement in childNodechildNodeNodeElementElement)
                                {
                                    Response.Write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + childNodechildNodeNodeElementChileElement.InnerText+"<br/>");
                                }
                            }
                            else {
                                Response.Write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + childNodechildNodeNodeElementElement.InnerText + "<br/>");
                            }
                           // Response.Write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + childNodechildNodeNodeElementElement.InnerText);
                        }
                    }else{
                        Response.Write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + childNodeNodeElement.InnerText);
                    }
                }
            }
            else {
                Response.Write("Value is   "+node.InnerText);
            }
            
        }








Answers (1)