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

  • Home
  • SEARCH
  • 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 8455133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:12:24+00:00 2026-06-10T12:12:24+00:00

I just want to select the target element which has name attribute value =

  • 0

I just want to select the target element which has “name” attribute value = ‘syslog’. Anyway, I always get an NullReferenceException. Can anyone help me to figure out what is the problem?

—————- My code ——————————————-

XmlNode root = _configFile.DocumentElement; // root is not none, and is correct.
XmlNode syslogNode = root.SelectSingleNode("descendant::targets/target[@name='syslog']"); // the syslogNode is null

—————–My XML file ————————————–

<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

  <extensions>
    <add assembly="NLog.Targets.Syslog" />
  </extensions>

  <targets>
    <target name="syslog" xsi:type="Syslog" syslogserver="127.0.0.1" port="514" facility="Local7" />
    <target name="file" xsi:type="File" layout="${level} | ${longdate} | ${callsite:className=true:fileName=false:includeSourcePath=false:methodName=true} | ${message} ${exception:format=tostring}"
            fileName="${specialfolder:folder=LocalApplicationData}/Televic Conference/CoCon/Log/server_log_${shortdate}.txt"
            archiveFileName="${specialfolder:folder=LocalApplicationData}/Televic Conference/CoCon/Log/Archives/server_log.{#}.txt"
            archiveEvery="Day" archiveNumbering="Rolling" maxArchiveFiles="20" concurrentWrites="true" keepFileOpen="false"/>
    <target name="console" xsi:type="ColoredConsole" layout="${longdate}: ${message}"/>
    <target name="debug" xsi:type="OutputDebugString" layout="${longdate}: ${message}"/>
  </targets>

  <rules>
    <logger name="*" minLevel="Trace" appendTo="syslog"/>
    <logger name="*" minlevel="Trace" writeTo="file" />
  </rules>
</nlog>
  • 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-06-10T12:12:25+00:00Added an answer on June 10, 2026 at 12:12 pm

    Use LINQ2XML..Its cool

    XElement doc = XElement.Load("yourStream.xml");
    XNamespace g = "http://www.nlog-project.org/schemas/NLog.xsd";//global namespace g
    
    foreach (var itm in doc.Descendants(g + "targets").Where(x=>x.Atrribute("name").Value=="syslog"))
    {
    itm;//your required node
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Simple question, I just want to select the text from the <Template> tag. Here's
Just want to know how to read an attribute of a parent node from
Just want to ask can netbean IDE get connected to clearcase remote client server
I just want to ask if anybody has done something like this. Basically, it's
I have a select element, that posts (just fine) when changed using $.post. But
i have 6 element and i want to select the 5th element (with jQuery)
I want to be able to select all <a> tags which exactly match a
Just want to ask if i can use Custom Validator in client side without
Just want to make sure one thing. In a windows machine (either a desktop
Just want to know if publishing an application on Google play is allowed using

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.