xml file reading

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kishoreyakkali
    New Member
    • Feb 2007
    • 1

    #1

    xml file reading

    Hi,
    This is kishore, i want to read an xml file in c#. the xml file as follows..
    Here i want to retrive the all the element node values and text values between <PaymentGroup > to </PaymentGroup>.
    can u plz help me..

    Thank you............ ....


    <paymentGroup >
    <payfileSequenc e>0001</payfileSequence >
    <outMethod>BOFA 820</outMethod>
    <bankName>BAN K OF AMERICA</bankName>
    <standardFormat >X12-820</standardFormat>
    <version>2.01 </version>
    <date>2006060 1</date>
    <clientCode>PCS </clientCode>
    <fileName>d:\da ta\newdem_rele\ out\BOFA0001.tx t</fileName>
    <scriptName>SEN DTOBOFA</scriptName>
    <senderID />
    <receiverID />
    <companyID />
    <regionalID />
    <branchID />
    <centralBankRep orting />
    <hashTotals>
    <noofPayments>1 </noofPayments>
    <totalAmount>87 </totalAmount>
    <other />
    </hashTotals>
    <extradetails duns="4" id="010">
    <extradetails duns="6" id="100">
    </paymentGroup>
  • vee10
    New Member
    • Oct 2006
    • 141

    #2
    hi,

    This is the solution for u r problem
    Code:
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Xml;
    
    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load("C:\\Users\\v-nacher\\Desktop\\payment.xml"); //Path of the xml file 
                Console.Write(xmlDoc.SelectSingleNode("//paymentGroup").InnerText.ToString());
                Console.ReadLine();
            }
        }
    }
    and for a particular node write xpath

    for example //paymentGroup/clientCode like that

    Comment

    Working...