Link to home
Start Free TrialLog in
Avatar of mattkovo
mattkovo

asked on

Help reading XML from asp.net c#

I have a function that reads XML from an API. The problem I have is reading from a dynamic tag name. The tag always starts with "Voids_" but has an integer following it. No other tags will ever have the word "Void" in it if that helps. Here is what I have right now.


     private void GetSalesInfo()
        {
            XDocument GetData;
            XElement NetSales, LaborDollar, LaborPercent, Voids;

            GetData = XDocument.Load("http://myURL);
            NetSales = GetData.Element("SalesInfo").Element("Net_Sales");
            LaborDollar = GetData.Element("SalesInfo").Element("Labor_Dollar");
            LaborPercent = GetData.Element("SalesInfo").Element("Labor_Percent");
            Voids = GetData.Element("SalesInfo").Element(" ---where name like "%Void_%)";
            txtNetSales.Text = NetSales.Value;
            txtLaborDollar.Text = LaborDollar.Value;
            txtLaborPercent.Text = LaborPercent.Value;
        }


This is the line I need help with:
Voids = GetData.Element("SalesInfo").Element(" ---where name like "%Void_%)";

It will ALWAYS be the 4th tag in the list.

Any help here?
Avatar of guvera
guvera
Flag of India image

ASKER CERTIFIED SOLUTION
Avatar of joebone2
joebone2

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mattkovo
mattkovo

ASKER

That did the trick!  Thanks for the help!