Hack Forums
[.NET] Inserting from xml to datebase in vb - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] Inserting from xml to datebase in vb (/showthread.php?tid=5355816)



Inserting from xml to datebase in vb - antibiotic1 - Jul 29, 2016

I have xml that looks like this

Code
<?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

Code
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 and my program executes it just skips the foreach, it dont go inside...


* - Zilog80 - Jul 29, 2016

From my 101 XML/JSON : https://hackforums.net/showthread.php?tid=5353651

[Image: Ieci4qm.jpg]

Result:

[Image: 338vFcN.jpg]

Table definitions:

[Image: HxglNPZ.jpg]

Edited:

If you want to save your aka members just:

PHP Code

<?php 
param
(0).Value = myData.sdnEntry.akaList.aka.uid
param
(1).Value = myData.sdnEntry.akaList.aka.lastName
param
(2).Value = myData.sdnEntry.akaList.aka.type 

First they ignore you, then they laugh at you, then they fight you, and then you win.