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 830589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:04:07+00:00 2026-05-15T04:04:07+00:00

I have the following XML which I am trying to query with XDocument: <E2ETraceEvent

  • 0

I have the following XML which I am trying to query with XDocument:

<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent">
    <System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system">
        <EventID>589828</EventID>
        <Type>3</Type>
        <SubType Name="Information">0</SubType>
        <Level>8</Level>
        <TimeCreated SystemTime="2010-06-01T09:45:15.8102117Z" />
        <Source Name="System.ServiceModel" />
        <Correlation ActivityID="{00000000-0000-0000-0000-000000000000}" />
        <Execution ProcessName="w3wp" ProcessID="5012" ThreadID="5" />
        <Channel />
        <Computer>TESTSERVER3A</Computer>
    </System>
    <ApplicationData>
        <TraceData>
            <DataItem>
                <TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Information">
                    <TraceIdentifier>http://msdn.microsoft.com/en-GB/library/System.ServiceModel.Activation.WebHostCompilation.aspx</TraceIdentifier>
                    <Description>Webhost compilation</Description>
                    <AppDomain>/LM/W3SVC/257188508/Root-1-129198591101343437</AppDomain>
                    <Source>System.ServiceModel.Activation.ServiceParser/39498779</Source>
                    <ExtendedData xmlns="http://schemas.microsoft.com/2006/08/ServiceModel/StringTraceRecord">
                        <VirtualPath>/Service.svc</VirtualPath>
                    </ExtendedData>
                </TraceRecord>
            </DataItem>
        </TraceData>
    </ApplicationData>
</E2ETraceEvent>

Executing the following code returns null for xEl1 except when I manually remove the namespaces:

XDocument xDoc = XDocument.Parse(CurrentString);
XElement xEl1 = xDoc.Element("E2ETraceEvent");
XElement xEl2 = xEl1.Element("System");
XElement xEl3 = xEl2.Element("Correlation");
XAttribute xAtt1 = xEl3.Attribute("ActivityID");
String sValue = xAtt1.Value;

How do you write code to extract the Guid in XDocument?

  • 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-15T04:04:08+00:00Added an answer on May 15, 2026 at 4:04 am

    Try this, works for me

        XNamespace nsSys = "http://schemas.microsoft.com/2004/06/windows/eventlog/system";
        XElement xEl2 = xDoc.Element(nsSys + "System");
        XElement xEl3 = xEl2.Element(nsSys + "Correlation");
        XAttribute xAtt1 = xEl3.Attribute("ActivityID");
        String sValue = xAtt1.Value;
    

    You need to use Namespaces.

    Full source for trial

            public static void Main()
            {
                XElement xDoc = XElement.Parse(
                @"<E2ETraceEvent xmlns=""http://schemas.microsoft.com/2004/06/E2ETraceEvent""> 
        <System xmlns=""http://schemas.microsoft.com/2004/06/windows/eventlog/system""> 
            <EventID>589828</EventID> 
            <Type>3</Type> 
            <SubType Name=""Information"">0</SubType> 
            <Level>8</Level> 
            <TimeCreated SystemTime=""2010-06-01T09:45:15.8102117Z"" /> 
            <Source Name=""System.ServiceModel"" /> 
            <Correlation ActivityID=""{00000000-0000-0000-0000-000000000000}"" /> 
            <Execution ProcessName=""w3wp"" ProcessID=""5012"" ThreadID=""5"" /> 
            <Channel /> 
            <Computer>TESTSERVER3A</Computer> 
        </System> 
        <ApplicationData> 
            <TraceData> 
                <DataItem> 
                    <TraceRecord xmlns=""http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord"" Severity=""Information""> 
                        <TraceIdentifier>http://msdn.microsoft.com/en-GB/library/System.ServiceModel.Activation.WebHostCompilation.aspx</TraceIdentifier> 
                        <Description>Webhost compilation</Description> 
                        <AppDomain>/LM/W3SVC/257188508/Root-1-129198591101343437</AppDomain> 
                        <Source>System.ServiceModel.Activation.ServiceParser/39498779</Source> 
                        <ExtendedData xmlns=""http://schemas.microsoft.com/2006/08/ServiceModel/StringTraceRecord""> 
                            <VirtualPath>/Service.svc</VirtualPath> 
                        </ExtendedData> 
                    </TraceRecord> 
                </DataItem> 
            </TraceData> 
        </ApplicationData> 
    </E2ETraceEvent>");
    
                XNamespace nsSys = "http://schemas.microsoft.com/2004/06/windows/eventlog/system";
                XElement xEl2 = xDoc.Element(nsSys + "System");
                XElement xEl3 = xEl2.Element(nsSys + "Correlation");
                XAttribute xAtt1 = xEl3.Attribute("ActivityID");
                String sValue = xAtt1.Value;
    
                Console.WriteLine("sValue = {0}", sValue);
    
                Console.ReadKey();
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following xml, from which I am trying to remove all xmlns
I have the following XML which I load via XDocument.Load(uri) or XElement.Load(uri) . I
I have the following XML from which I am trying to generate HTML files.
I have the following code which is trying to post xml constructed data to
I have following xml and I want to fetch the value of node which
I have the following thing to achieve in Android(newbie). I have an xml which
I have an xml document which consists of a number of the following: -
I have an XML document which contains nodes like following:- <a class=custom>test</a> <a class=xyz></a>
I have the following code which outputs an object to an XML file: using
I have a large XML file which in the middle contains the following: <ArticleName>Article

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.