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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:40:55+00:00 2026-05-30T12:40:55+00:00

I have a XML file, that looks like this inside: <Data> <INFO> .. …

  • 0

I have a XML file, that looks like this inside:

<Data>
    <INFO>
        ..
        ...
        <JOB_NAME value="filename.pdf"/>
        <useless_info value="some_info"/>
        <TIMESTAMP value="20120210075304"/>
        <more_useless_info value="012345"/>
        ...
        ..
    </INFO>
    <INFO>
        ..
        ...
        <JOB_NAME value="filename2.pdf"/>
        <useless_info value="some_info"/>
        <TIMESTAMP value="20120210073487"/>
        <more_useless_info value="012345"/>
        ...
        ..
    </INFO>
</Data>

What i want to do, is write specific info to strings, so that later on i can write these to a text file or new XML file.
I found this example here: http://www.csharp-examples.net/xml-nodes-by-name/
And i have this code a little bit working.
Not fully, because it it not getting the values.
my code looks like this:

    XmlDocument xmlDoc = new XmlDocument();
    xmlDoc.Load(FileNameTextBox.Text);

    XmlNodeList xnList = xmlDoc.SelectNodes("/Data/INFO");
    foreach (XmlNode xn in xnList)
    {
        string jobName = xn["JOB_NAME"].InnerText;
        string timeStamp = xn["TIMESTAMP"].InnerText;
        MessageBox.Show(timeStamp + jobName);  //for testing

    }

I think this has to do with the fact that the info that i want to get, is not boxed in like <box>info</box>
What i cant find is how i could get the info in my caseout of the xml file now.
Could someone lent me a hand?
thank you!

  • 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-30T12:40:56+00:00Added an answer on May 30, 2026 at 12:40 pm

    You need to select the JOB_NAME and TIMESTAMP child nodes of each INFO node, then get their attributes, then get the Value of the “value” attribute.

    XmlDocument xmlDoc = new XmlDocument();
    xmlDoc.Load(FileNameTextBox.Text);
    
    XmlNodeList xnList = xmlDoc.SelectNodes("/Data/INFO");
    foreach (XmlNode xn in xnList)
    {
        string jobName = xn.SelectSingleNode("JOB_NAME").Attributes["value"].Value;
        string timeStamp = xn.SelectSingleNode("TIMESTAMP").Attributes["value"].Value;
        MessageBox.Show(timeStamp + jobName);  //for testing
    }
    

    Be careful with this though as you are likely to get a NullReferenceException if any of the INFO nodes don’t contain both a JOB_NAME and TIMESTAMP Node, and also if either of those do not have an attribute “value”.

    To answer your comment below:

    string vendorName = xn.SelectSingleNode("JOB_NAME").Attributes["vendor-name"].Value;
    string mediaName = xn.SelectSingleNode("JOB_NAME").Attributes["media-name"].Value; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML file that looks like this... <foo> <bar>$VALUE$</bar> </foo> Is there
I have an xml file that looks like this: <args> <sometag value=abc /> <anothertag
--edited for clarity (hopefully) I have an XML file that looks something like this:
I have an eclipse's .classpath file that looks like this: <?xml version=1.0 encoding=UTF-8?> <classpath>
ok, so, i have an xml file that looks like this: <?xml version=1.0?> <Users>
I have a XML file that looks like this <Licence> <Name>Test company</Name> <Version>1.1.1.1</Version> <NumberOfServer>2</NumberOfServer>
So I have an XML file that looks a little like this <xml> <post>
I have an XML file that looks like this: <country> <routes> <SourceCountry>Ireland</SourceCountry> <SourcePort>Larne</SourcePort> <DestinationCountry>UK</DestinationCountry>
I have an XML file that looks like this: <rss> <channel> <title>title</title> <link>link</link> <description>description</description>
I have an XML File that looks like this: <?xml version='1.0' encoding='UTF-8' standalone='yes' ?>

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.