Question: I have xml that looks like this 

```
<?xml version="1.0" standalone="yes"?>
<sdnList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tempuri.org/sdnList.xsd">
  <sdnEntry>
    <uid>36</uid>
    <lastName>AEROCARIBBEAN AIRLINES</lastName>
    <sdnType>Entity</sdnType>
    <programList>
      <program>CUBA</program>
    </programList>
    <akaList>
      <aka>
        <uid>12</uid>
        <type>a.k.a.</type>
        <category>strong</category>
        <lastName>AERO-CARIBBEAN</lastName>
      </aka>
    </akaList>
    <addressList>
      <address>
        <uid>25</uid>
        <city>Havana</city>
        <country>Cuba</country>
      </address>
    </addressList>
  </sdnEntry>

```

And the code that i am using to insert starts like this

```
node_list = xml_doc.SelectNodes("//sdnEntry")
        For Each node In node_list
            If CheckElement("lastName", node) <> "" Then
                sql = "INSERT INTO us_sdnentry (uid_,lastname,sdntype) VALUES "
                sql &= "('" & node.SelectNodes("./uid").Item(0).InnerText & "','" & CheckElement("lastName", node) & "','" & node.SelectNodes("./sdnType").Item(0).InnerText & "'")"
                db_sql.RunSql(sql)
            End If
            sql = "".........

```

The problem is that when i am debugging, when my program executes it just skips the foreach, it dont go inside...

Answer: 
At first sight your code looks good, but when you put it in debug, you see that something is not working properly. 

The main problem is the **xml namespace**. You can see how to perform **XPath** query with namespaces looking this: [Problem running xpath query with namespaces](https://stackoverflow.com/questions/3804055/problem-running-xpath-query-with-namespaces).

Eventhough i love **XElement** in (System.Xml.Linq assembly) as Jurgen says, you can start facing your problem tring this code:

```
node_list = xml_doc.SelectNodes("//*[local-name() = 'sdnEntry']")
For Each node In node_list
     'Here your code '
Next

```

You can by-pass the namespace problem using the local-name property. 
So change your XPath query to: 

> 
> `//*[local-name() = 'yourtag']`
> 
> 
> 

And you'll see that now your program will start looping inside the **For Each**.
Your program does not skip the For Each. `node_list` is empty (Check `node_list.Count()`)

I don't know why this does not work because your XPath Query looks good. But since you are not making any query and just iterate over the nodes. I would suggest an alternative.

I am a big fan of the simplicity and usage of XElement (System.Xml.Linq assembly)

```
dim root = XElement.Load(fileName or stream or uri or reader)
For Each node in root.Elements("sdnEntry")
    If Not String.IsNullOrEmpty(node.Element("lastname")) Then
       ...
    End If
Next

```