如何将以下XML导入SQL表,使用IP tpl表示的子元素将因每个xml记录的数量而异。 我认为主要问题是处理可变数量的子元素,如果这是正确的术语?
由于
<?xml version="1.0" encoding="utf-8"?>
<PportTimetable xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" timetableID="20161018020822" xmlns="http://www.thalesgroup.com/rtti/XmlTimetable/v8">
<Journey rid="201610188012733" uid="P12733" trainId="2J27" ssd="2016-10-18" toc="AW">
<OR tpl="MCHYNLT" act="TB" ptd="21:43" wtd="21:43" />
<IP tpl="DOVYJN" act="T " pta="21:49" ptd="21:49" wta="21:48:30" wtd="21:49:30" />
<IP tpl="PENHELG" act="R " plat="1" pta="21:58" ptd="21:58" wta="21:58:30" wtd="21:59" />
<IP tpl="ABDVY" act="T " plat="1" pta="22:01" ptd="22:02" wta="22:01:30" wtd="22:02" />
<IP tpl="TYWYN" act="T X " plat="2" pta="22:11" ptd="22:15" wta="22:11" wtd="22:15" />
<IP tpl="TONFNAU" act="R " plat="1" pta="22:18" ptd="22:18" wta="22:19" wtd="22:19:30" />
<IP tpl="LYNGRIL" act="R " plat="1" pta="22:25" ptd="22:25" wta="22:25:30" wtd="22:26" />
<IP tpl="FRBN" act="T " plat="1" pta="22:32" ptd="22:33" wta="22:33" wtd="22:33:30" />
<IP tpl="MFAM" act="R " plat="1" pta="22:35" ptd="22:35" wta="22:35:30" wtd="22:36" />
<IP tpl="BRMOUTH" act="T X " pta="22:44" ptd="22:46" wta="22:45" wtd="22:46:30" />
<IP tpl="LNAB" act="R " plat="1" pta="22:49" ptd="22:50" wta="22:50" wtd="22:51" />
<IP tpl="TALB" act="R " plat="1" pta="22:53" ptd="22:53" wta="22:55" wtd="22:55:30" />
<IP tpl="DYFRYNA" act="R " plat="1" pta="22:56" ptd="22:56" wta="22:58" wtd="22:58:30" />
<IP tpl="LBDR" act="R " plat="1" pta="23:00" ptd="23:00" wta="23:02" wtd="23:02:30" />
<IP tpl="PSRN" act="R " plat="1" pta="23:03" ptd="23:03" wta="23:04:30" wtd="23:05" />
<IP tpl="LNDW" act="R " plat="1" pta="23:05" ptd="23:05" wta="23:06:30" wtd="23:07" />
<IP tpl="HRLC" act="T " plat="2" pta="23:10" ptd="23:13" wta="23:12" wtd="23:13" />
<IP tpl="TYGWYN" act="R " plat="1" pta="23:16" ptd="23:16" wta="23:17" wtd="23:17:30" />
<IP tpl="TLSRNAU" act="R " plat="1" pta="23:19" ptd="23:19" wta="23:19:30" wtd="23:20" />
<IP tpl="LNDC" act="R " plat="1" pta="23:22" ptd="23:22" wta="23:22:30" wtd="23:23" />
<IP tpl="PRHN" act="T " plat="1" pta="23:25" ptd="23:26" wta="23:25:30" wtd="23:26" />
<IP tpl="MINFORD" act="T " plat="1" pta="23:29" ptd="23:29" wta="23:29" wtd="23:29:30" />
<IP tpl="PRTHMDG" act="T " pta="23:37" ptd="23:37" wta="23:36:30" wtd="23:37:30" />
<IP tpl="CRICCTH" act="T " plat="1" pta="23:45" ptd="23:45" wta="23:44:30" wtd="23:45" />
<IP tpl="PENYCHN" act="R " plat="1" pta="23:50" ptd="23:50" wta="23:50:30" wtd="23:51:30" />
<IP tpl="ABRE" act="R " plat="1" pta="23:53" ptd="23:53" wta="23:54:30" wtd="23:55" />
<DT tpl="PWLHELI" act="TF" plat="1" pta="23:59" wta="23:59" />
</Journey>
<Journey rid="201610186765436" uid="C65436" trainId="2S07" ssd="2016-10-18" toc="EM">
<OR tpl="NTNG" act="TB" plat="4" ptd="07:35" wtd="07:35" />
<PP tpl="NTHRFLJ" wtp="07:40" />
<IP tpl="BINGHAM" act="T " plat="2" pta="07:49" ptd="07:49" wta="07:48:30" wtd="07:49" />
<IP tpl="ASLCKTN" act="T " plat="1" pta="07:53" ptd="07:53" wta="07:52:30" wtd="07:53" />
<PP tpl="BOTESWJ" wtp="07:57" />
<IP tpl="BOTESFD" act="T " plat="2" pta="07:59" ptd="07:59" wta="07:59" wtd="07:59:30" />
<PP tpl="ALNGJN" wtp="08:06:30" />
<PP tpl="GTHMNBJ" wtp="08:10" />
<IP tpl="GTHM" act="T RM" plat="4" pta="08:12" ptd="08:16" wta="08:12" wtd="08:16" />
<PP tpl="GTHMNBJ" wtp="08:18" />
<PP tpl="ALNGEJN" wtp="08:22" />
<PP tpl="ALNGNJN" wtp="08:22:30" />
<IP tpl="ANCASTR" act="T " plat="2" pta="08:34" ptd="08:34" wta="08:34" wtd="08:34:30" />
<IP tpl="RAUCEBY" act="T " plat="2" pta="08:40" ptd="08:40" wta="08:40" wtd="08:42" />
<IP tpl="SLEFD" act="T " plat="1" pta="08:44" ptd="08:45" wta="08:46" wtd="08:47:30" />
<IP tpl="HCKNGTN" act="T " plat="2" pta="08:52" ptd="08:52" wta="08:54" wtd="08:54:30" />
<PP tpl="HBRTBDG" wtp="09:03:30" />
<IP tpl="BOSTON" act="T " plat="2" pta="09:11" ptd="09:12" wta="09:11" wtd="09:12" />
<PP tpl="SIBSEY" wtp="09:19:30" />
<PP tpl="BELWTRJ" wtp="09:26" />
<IP tpl="WAINFLT" act="T " plat="2" pta="09:36" ptd="09:36" wta="09:35:30" wtd="09:36:30" />
<DT tpl="SKEGNES" act="TF" pta="09:49" wta="09:48" />
</Journey>
在提出问题之前,您是否彻底搜索过答案?分享您的研究有助于每个人告诉我们您在本网站或其他地方找到了什么,以及为什么它不能满足您的需求。这表明你花时间试图帮助自己,这使我们不再重复明显的答案,最重要的是,它可以帮助你获得更具体和相关的答案!
答案 0 :(得分:0)
嗨,您可以使用SQL Loader将XML数据导入SQL中的表中。有一个选项作为SQL加载器,它是一个批处理,在点击时将数据导入表。您需要做的是,有一个日志文件,控制文件和批处理文件,并在控制文件中有一个代码,它应该如何加载。如果您可以提供示例XML数据和表结构,将有助于为您提供准确的解决方案 请查看此参考资料 - Can Oracle SQL*Loader process XML?