Help Parsing XML in C Sharp

 I am TRYING to do something, supposibly simple in C#, which i know how to do in ASP.NET
Please Help

I have the code for both form data and Code behind

I simple want to pass the Path of the XML to the Function and have it display data


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ssrf._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="" >
<head runat="server">
    <title>Untitled Page</title>
    <form id="form1" runat="server">
                 string xmlPath="c:\itt\7763V.xml";  
//-------------------Code Behind--------------
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

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

        private void ProcessXml(string xmlPath)
            XmlDocument doc = new XmlDocument();


            // Set up namespace manager for XPath    
            XmlNamespaceManager nsMgr = new XmlNamespaceManager(doc.NameTable);

            nsMgr.AddNamespace("ddms", "urn:us:gov:dod:standard:ssrf:1.2.4.b");
            nsMgr.AddNamespace("xs", "");
            nsMgr.AddNamespace("s", "urn:us:gov:dod:standard:ssrf:1.2.4.b");
            nsMgr.AddNamespace("my", "");

            XmlNodeList txrx2 = doc.SelectNodes("s:SSRF/s:Body/s:TxRx", nsMgr);

            foreach (XmlNode node in txrx2)

        private void WalkNodes(XmlNode iXmlNode)
            if (iXmlNode.InnerText != null)
                Response.Write("Element - " + iXmlNode.Name + ": " + iXmlNode.InnerText + "<br>");
            if (iXmlNode.Attributes != null)
                if (iXmlNode.Attributes.Count > 0)
                    Response.Write(iXmlNode.Name + " Attributes: " + "<br>");
                    int Atcount;
                    //Atcount = (iXmlNode.Attributes.Count - 1);
                    //for (int atrib = 0;Atcount;atrib++) //<---- error i get is - Cannot convert type 'int' to 'bool'
                    //    Response.Write("     " + iXmlNode.Attributes(atrib).Name + " - " + iXmlNode.Attributes(atrib).Value + "<br>");
                    //error i get is - System.XML.XMLNode.Attributes is a 'property' but used like a 'method'
                    // } 

                    // Get the node's attributes
                    XmlAttributeCollection attCol = iXmlNode.Attributes;

                    // Print them for testing
                    Response.Write(attCol[0].Value + "<br/>");


            foreach (XmlNode child in iXmlNode.ChildNodes)



Open in new window
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
What version of ASP.NET do you have?  You might be able to use an XmlDataSource...
AshokSr. Software EngineerCommented:
Atcount = (iXmlNode.Attributes.Count - 1);
for (int atrib = 0;atrib <= Atcount;atrib++) //<---- error i get is - Cannot convert type 'int' to 'bool'
  Response.Write("     " + iXmlNode.Attributes(atrib).Name + " - " + iXmlNode.Attributes(atrib).Value + "<br>");


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
anarki_jimbelSenior DeveloperCommented:
OK, I believe  you need to use square brackets to supply index for attributes:


ashok111 has fixed another error, I hope
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.