簡體   English   中英

如何使用 lambda(python) 從 s3 存儲桶將 xml 文件導出到 oracle 數據庫中的表中

[英]how to export xml file from a s3 bucket using lambda(python) into tables in an oracle database

我很難連接到我的 s3 存儲桶以使用 lambda 讀取 xml 文件,我正在使用“xml.estree.ElementTree”。 然后我希望能夠將它們上傳到 oracle 中的表中。

示例:file.xml

<row>
 <Id >1234</Id>
 <Name>Jon</Name>
</row>
<row>
 <Id>1244</Id>
 <Name>Doe</Name>
</row>

任何幫助或指導將不勝感激。

使用 Xml Linq 將 xml 放入數據表中:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;
using System.Data;

namespace ConsoleApplication40
{
    class Program
    {
        const string FILENAME = @"c:\temp\test.xml";
        static void Main(string[] args)
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("Id", typeof(int));
            dt.Columns.Add("Name", typeof(string));

            XDocument doc = XDocument.Load(FILENAME);

            foreach (XElement row in doc.Descendants("row"))
            {
                dt.Rows.Add(new object[] { (string)row.Element("Id"), (string)row.Element("Name")});
            }

        }
    }

}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM