Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6079355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:56:13+00:00 2026-05-23T10:56:13+00:00

<?xml version=1.0 encoding=utf-8?> <!DOCTYPE Report SYSTEM https://abc.mycompany.com/abc/processingreports/processeddtd/abcd_1_8.dtd> <Report Name=Daily TRANSACTIONS Version=1.8 xmlns=https://abc.mycompany.com/abc/processingreports/processeddtd/abcd_1_8.dtd OrgID=ABC_PQR StartDate=2011-03-10T00:00:00+00:00

  • 0
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE Report SYSTEM "https://abc.mycompany.com/abc/processingreports/processeddtd/abcd_1_8.dtd">
<Report Name="Daily TRANSACTIONS"
        Version="1.8"
        xmlns="https://abc.mycompany.com/abc/processingreports/processeddtd/abcd_1_8.dtd"
        OrgID="ABC_PQR" StartDate="2011-03-10T00:00:00+00:00" EndDate="2011-03-11T00:00:00+00:00">
    <Requests>
        <Request ID="2"
                 Date="2011-03-10T00:21:14+00:00"
                 OrderNumber="1">
            <BillTo>
                <FirstName />
            </BillTo>
            <LineItems>
                <LineItem Number="0">
                    <Quantity />
                </LineItem>
            </LineItems>
        </Request>
        <Request ID="2"
                 Date="2011-03-10T00:21:14+00:00"
                 OrderNumber="1">
                 TransactionNumber="389958330911111">
            <BillTo>
                <FirstName>A</FirstName>
            </BillTo>
            <LineItems>
                <LineItem Number="0">
                    <Quantity>1</Quantity>
                </LineItem>
            </LineItems>
            <UniqueData>
                <UniqueNumber>11111111111111111111111111111</UniqueNumber>
            </UniqueData></Request></Requests></Report>

In above XML file using Linq i just
want to extract OrderNumber and
UniqueNumber
OrderNumber=”1″
11111111111111111111111111111

Any ideas, suggestions to extract these details?

I can select elements from above xml file but UniqueNumber is not associated with OrderNumber

I am looking for something below (ignore lines where UniqueNumber is not present)
OrderNumber – assosicated UniqueNumber

Update
In “requiredElements” i am expecting two coulmns OrderNumber and UniqueNumber and holding associated values with each other as 1 and 11111 and so one

 #region FileOpen with UTF8 Encoding

 TextReader sr = new StreamReader(cFileName, Encoding.UTF8);
 XDocument reportfile = XDocument.Load(sr, LoadOptions.SetBaseUri);
 XElement xd = XElement.Parse(reportfile.ToString());
 sr.Close();


 #endregion

 XNamespace ns = xd.Attribute("xmlns").Value;

 var requiredElements = (from resultquery in reportfile.Descendants()
                          select new
                          {
                             OrderNumber = resultquery.Attribute("OrderNumber"),
                             UniqueNumber= (string)resultquery.Element(AddNameSpace(ns, "UniqueNumber")),
                          }
                      );
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:56:14+00:00Added an answer on May 23, 2026 at 10:56 am

    Here is some sample:

        XDocument doc = XDocument.Load(@"file.xml");
        XNamespace df = doc.Root.Name.Namespace;
        var results = from request in doc.Descendants(df + "Request")
                      where request.Elements(df + "UniqueData").Elements(df + "UniqueNumber").Any()
                      select new
                      {
                          ordNumber = (int)request.Attribute("OrderNumber"),
                          uniqueNumber = (decimal)request.Element(df + "UniqueData").Element(df + "UniqueNumber")
                      };
        foreach (var result in results)
        {
            Console.WriteLine("{0}-{1}", result.ordNumber, result.uniqueNumber);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Wikipedia's example of XHTML-MP : <?xml version=1.0 encoding=UTF-8?> <!DOCTYPE html PUBLIC -//WAPFORUM//DTD XHTML Mobile
I've got the following JNLP: <?xml version=1.0 encoding=UTF-8?> <!DOCTYPE jnlp PUBLIC -//Sun Microsystems, Inc//DTD
I have the following html page: <?xml version=1.0 encoding=UTF-8?> <!DOCTYPE html PUBLIC -//W3C//DTD XHTML
I have the following snippet: <?xml version=1.0 encoding=UTF-8?> <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0
I've a XHTML structure like this: <?xml version=1.0 encoding=utf-8 ?> <!DOCTYPE html PUBLIC -//W3C//DTD
I have the following xml snippet: <?xml version=1.0 encoding=UTF-8 ?> <!DOCTYPE sqlMap PUBLIC -//ibatis.apache.org//DTD
I have this html doc: <?xml version=1.0 encoding=utf-8?><!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.1//EN http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd>
<?xml version=1.0 encoding=UTF-8 standalone=no?> <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.1//EN http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd> <html xmlns=http://www.w3.org/1999/xhtml> <head>
I have this piece of html: <?xml version=1.0 encoding=UTF-8?> <!DOCTYPE html PUBLIC -//W3C//DTD XHTML
I have main page that looks like this: <?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.