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

The Archive Base Latest Questions

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

I try many different solution on this site and none seems to work for

  • 0

I try many different solution on this site and none seems to work for me .
I getting a xml file from a website and it’s returned to me in a string.

using the code below I need to read the nodes in the “entry” section of the xml file.
but it always comes up “0” meaning no nodes found. the only thing left I think is the XML file is not correct?

any help would be great…

——————code below ————:

//gets the xml file
 string WeatherXML = HttpPost("http://weather.gov/alerts-beta/wwaatmget.php?x=MIC159", "");

//create a xmldoc object.. 
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

//load the object with the xml file from the web...
doc.LoadXml(WeatherXML);

//go to the main node.. 
XmlNodeList nodes = doc.SelectNodes("/feed/entry");

//I also tried ....
//doc.SelectNodes("//feed/entry");
//doc.SelectNodes("/entry");
//doc.SelectNodes("//entry");


//loop through the nodes (here is where the nodelist is always empty..

foreach (XmlNode node in nodes)
   {
      string msgType = node["cap:msgType"].InnerText;
      string areaDesc = node["cap:areaDesc"].InnerText;
      string summary = node["summary"].InnerText;
      string title = node["title"].InnerText;
      string link = node["link"].InnerText;
   }

——————————XML file below——————

<?xml version = '1.0' encoding = 'UTF-8' standalone = 'no'?>

<!--
This atom/xml feed is an index to active advisories, watches and warnings issued
by the National Weather Service.  This index file is not the complete Common
Alerting Protocol (CAP) alert message.  To obtain the complete CAP alert,
please follow the links for each entry in this index.  Also note the CAP
message uses a style sheet to convey the information in a human readable
format.  Please view the source of the CAP message to see the complete data
set.  Not all information in the CAP message is contained in this index of
active alerts.
-->
<feed
xmlns = 'http://www.w3.org/2005/Atom'
xmlns:cap = 'urn:oasis:names:tc:emergency:cap:1.1'
xmlns:ha = 'http://www.alerting.net/namespace/index_1.0'
>

  <!-- http-date = Sun, 22 Aug 2010 07:06:00 GMT -->
  <id>http://www.weather.gov/alerts-beta/wwaatmget.php?x=MIC159</id>
  <generator>
  NWS CAP Server
  </generator>
  <updated>2010-08-22T19:06:00-04:00</updated>
  <author>
  <name>
  w-nws.webmaster@noaa.gov
  </name>
  </author>
  <title>
  Current Watches, Warnings and Advisories for Van Buren (MIC159) Michigan Issued by the National Weather Service
  </title>
  <link href='http://www.weather.gov/alerts-beta/wwaatmget.php?x=MIC159'/>
<entry>
<id>http://www.weather.gov/alerts-beta/wwacapget.php?x=MI20100822190600IWXRipCurrentStatementIWX20100823060000MI</id>
<updated>2010-08-22T15:06:00-04:00</updated>
<published>2010-08-22T15:06:00-04:00</published>
<author>
<name>w-nws.webmaster@noaa.gov</name>
</author>
<title>Rip Current Statement issued August 22 at 3:06PM EDT expiring August 23 at 2:00AM EDT by NWS NorthernIndiana http://www.crh.noaa.gov/iwx/</title>
<link href="http://www.weather.gov/alerts-beta/wwacapget.php?x=MI20100822190600IWXRipCurrentStatementIWX20100823060000MI"/>
<summary>...RIP CURRENT RISK REMAINS IN EFFECT UNTIL 2 AM EDT /1 AM CDT/ MONDAY... ...HIGH RISK OF RIP CURRENTS... HIGH WAVES ALONG THE SHORELINE WILL BRING AN INCREASED RISK OF RIP CURRENTS INTO THE EARLY MORNING HOURS OF MONDAY...CREATING DANGEROUS SWIMMING CONDITIONS.</summary>
<cap:effective>2010-08-22T15:06:00-04:00</cap:effective>
<cap:expires>2010-08-23T02:00:00-04:00</cap:expires>
<cap:status>Actual</cap:status>
<cap:msgType>Alert</cap:msgType>
<cap:category>Met</cap:category>
<cap:urgency></cap:urgency>
<cap:severity></cap:severity>
<cap:certainty></cap:certainty>
<cap:areaDesc>Berrien; Cass; La Porte; St. Joseph; Van Buren</cap:areaDesc>
<cap:geocode>
<valueName>FIPS6</valueName>
<value>018091 018141 026021 026027 026159</value>
</cap:geocode>
<cap:parameter>
<valueName>VTEC</valueName>
<value>/O.CON.KIWX.RP.S.0017.000000T0000Z-100823T0600Z/</value>
</cap:parameter>
</entry>
</feed>:"
  • 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-16T09:56:14+00:00Added an answer on May 16, 2026 at 9:56 am

    It’s because your XML root node has a namespace. The following should work:

    //load the object with the xml file from the web...
    doc.LoadXml(WeatherXML);
    XmlNamespaceManager nsMgr = new XmlNamespaceManager(doc.NameTable);
    nsMgr.AddNamespace("m", "http://www.w3.org/2005/Atom");
    
    //go to the main node.. 
    XmlNodeList nodes = doc.SelectNodes("m:feed", nsMgr);
    Console.WriteLine(nodes.Count);    // outputs 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.