【问题标题】:easiest way to extract Oracle form xml format data提取Oracle表单xml格式数据的最简单方法
【发布时间】:2021-06-04 17:54:56
【问题描述】:

我有几百个 oracle 表单,我将它们转换为 XML。我想提取任何可能对我有用的文本(值),以检查我拥有的所有表单之间的某些相互依赖关系。

我尝试将它们插入数据库中的完整 XML 格式的表中,但挑战是表的大小相当大,查询该表大约需要 10 分钟。

因此,我想从 XML 格式中删除所有不必要的文本,只保留所需的内容。

你有什么建议?我正在使用 python 和有用的信息形式,我将像块名称,写在 oracle 形式中的任何程序(在程序单元标记中)

另外,请注意我的 Oracle XML 格式是:

<?xml version = '1.0' encoding = 'UTF-8'?>
<Module version="111020200" xmlns="http://xmlns.oracle.com/Forms">
   <FormModule Name="TEST" DirtyInfo="true" Title="MODULE1" MenuModule="DEFAULT&amp;SMARTBAR" ConsoleWindow="WINDOW1">
      <Coordinate CharacterCellWidth="5" DefaultFontScaling="true" CoordinateSystem="Real" CharacterCellHeight="14" RealUnit="Point"/>
      <Block Name="BLOCK2" DirtyInfo="true" ScrollbarWidth="9" ScrollbarLength="135">
         <Item Name="ROUND_RULE" Prompt="round rule" YPosition="143" TabPageName="" XPosition="110" DirtyInfo="true" Width="45" PromptAttachmentOffset="11" PromptAlignOffset="1" CanvasName="CANVAS5" Height="14"/>
         <Item Name="ROUND_PREM" MaximumLength="28" YPosition="143" XPosition="215" DataType="Number" Prompt="round prem" TabPageName="" DirtyInfo="true" PromptAttachmentOffset="7" Width="102" PromptAlignOffset="1" CanvasName="CANVAS5" Height="14"/>
         <Item Name="ITEM7" YPosition="178" TabPageName="" Label="return" XPosition="142" DirtyInfo="true" Width="45" CanvasName="CANVAS5" Height="14" ItemType="Push Button">
            <Trigger Name="WHEN-BUTTON-PRESSED" TriggerText=":value := ffn_round_premium(:Round_rule,:Round_Prem);" DirtyInfo="true"/>
         </Item>
         <Item Name="VALUE" MaximumLength="28" YPosition="209" XPosition="145" DataType="Number" Prompt="value" TabPageName="" DirtyInfo="true" PromptAttachmentOffset="5" Width="97" PromptAlignOffset="2" CanvasName="CANVAS5" Height="14"/>
      </Block>
      <Canvas Name="CANVAS5" ViewportHeight="324" ViewportWidth="360" DirtyInfo="true" Width="360" Height="324" WindowName="WINDOW1"/>
      <ProgramUnit Name="FFN_ROUND_PREMIUM" ProgramUnitType="Function" ProgramUnitText="Function ffn_round_premium (P_Round_rule in varchar2,P_Rounded_Prem number) &amp;#10;RETURN NUMBER IS&amp;#10;   Cursor cr_round_premium  is   select v_calculation_type,v_round_needed,v_decimal_side,&amp;#10;                                        n_round_digits,v_round_method,n_round_to ,&amp;#10;                                        v_first_cut_digit_check &amp;#10;                                 from Gnlu_calc_rounding_rules   &amp;#10;                                 where v_round_rule_ref = p_round_rule;    &amp;#10;   Lv_cal_type varchar2(10);&#x9;&amp;#10;   Lv_round_needed varchar2(1);&#x9;   &amp;#10;   Lv_decimal_side varchar2(10);  &amp;#10;   Ln_round_digits number; &amp;#10;   Lv_round_method varchar2(10); &amp;#10;   Ln_round_to number; &amp;#10;   Lv_first_cut_digit_check varchar2(1);     &amp;#10;   Ln_last_digit number;  &amp;#10;   Ln_previous_digit number;&amp;#10;   ln_rounded_prem number := 0; &amp;#10;   ln_prem number := 0;&amp;#10;   ln_first_value number := 0;&amp;#10;   ln_temp number := 0;&amp;#10;   lv_temp varchar2(50); &amp;#10;begin           &amp;#10;   open  cr_round_premium ;&amp;#10;   fetch cr_round_premium into  Lv_cal_type,&amp;#10;                                Lv_round_needed,&amp;#10;                                Lv_decimal_side,&amp;#10;                                Ln_round_digits, &amp;#10;                                Lv_round_method,&amp;#10;                                Ln_round_to,&amp;#10;                                Lv_first_cut_digit_check;&amp;#10;   close    cr_round_premium; &amp;#10;   /*Round_needed = NO, then, the input value is returned back */  &amp;#10;   If lv_cal_type = 'P' then&amp;#10;&#x9;    If Lv_round_needed ='N' then&amp;#10;&#x9;    &#x9; ln_prem := p_rounded_prem;&amp;#10;&#x9;    elsif lv_round_needed = 'Y' then&amp;#10;&#x9;    &#x9; ln_rounded_prem := p_rounded_prem;&amp;#10;&#x9;       ln_first_value := p_rounded_prem;&amp;#10;         If lv_decimal_side = 'B' and lv_first_cut_digit_check = 'N' then&amp;#10;            ln_rounded_prem := floor(ln_rounded_prem);&amp;#10;            if ln_round_digits = 0 then&amp;#10;            &#x9; ln_round_digits := 1;&amp;#10;            end if;&#x9; &amp;#10;         elsif lv_decimal_side = 'A' and lv_first_cut_digit_check = 'N' then&amp;#10;&amp;#10;&#x9;     &#x9;    if floor(ln_rounded_prem) &lt;> ln_rounded_prem then&amp;#10;&#x9;     &#x9;    &#x9; lv_temp := substr(ln_rounded_prem ,instr(ln_rounded_prem ,'.',1)+1) ;  &amp;#10;&#x9;     &#x9;    &#x9; if substr(lv_temp,1,1) = 0 then&amp;#10;&#x9;     &#x9;    &#x9; &#x9;  lv_temp := 'ZERO';&amp;#10;&#x9;     &#x9;    &#x9; end if;&#x9;  &amp;#10;&#x9;&#x9;&#x9;         ln_rounded_prem:= substr(ln_rounded_prem ,instr(ln_rounded_prem ,'.',1)+1) ;  &amp;#10;&#x9;&#x9;&#x9;         ln_rounded_prem := substr(ln_rounded_prem,1,ln_round_digits);&amp;#10;&#x9;&#x9;&#x9; &#x9;    elsif floor(ln_rounded_prem) = ln_rounded_prem then    &amp;#10;&#x9;     &#x9; &#x9;     ln_rounded_prem := 0;&amp;#10;&#x9;&#x9;&#x9; &#x9;    end if;&amp;#10;&#x9;&#x9;&#x9; &#x9;    if ln_round_digits = 0 then&amp;#10;            &#x9; ln_round_digits := 1;&amp;#10;&#x9;&#x9;&#x9; &#x9;    end if;&amp;#10;&#x9;     &#x9; elsif lv_first_cut_digit_check = 'Y' and ln_round_digits = 0 then&amp;#10;&#x9;     &#x9;    ln_rounded_prem := round(ln_rounded_prem);&amp;#10;&#x9;     &#x9;    ln_prem := ln_rounded_prem;&amp;#10;&#x9;       end if;       &amp;#10;&#x9;     &amp;#10;&#x9;       if lv_decimal_side = 'A' and lv_round_method in ('F','C') and lv_first_cut_digit_check = 'N'  and Ln_round_digits &lt;> 0 then&amp;#10;&#x9;          If ln_round_to =  5  and lv_round_method = 'F' then     &amp;#10;&#x9;             if substr(ln_rounded_prem,length(ln_rounded_prem),1) >= 5  then&amp;#10;&#x9;&#x9;              ln_prem := substr(ln_rounded_prem,1,length(ln_rounded_prem)-1)  ||'5'; &amp;#10;&#x9;             elsif substr(ln_rounded_prem,length(ln_rounded_prem),1) &lt; 5  then    &amp;#10;&#x9;       &#x9;        ln_prem := substr(ln_rounded_prem,1,length(ln_rounded_prem)-1)  ||'0'; &amp;#10;&#x9;             end if;&#x9;  &amp;#10;&#x9;          End if;&amp;#10;&#x9;    &amp;#10;&#x9;          If ln_round_to =  5  and lv_round_method = 'C' then     &amp;#10;&#x9;             if lv_temp = 'ZERO'&#x9; then&amp;#10;&#x9;                ln_prem := substr(ln_rounded_prem,1,length(ln_rounded_prem)-1)||'0'; &#x9;&amp;#10;&#x9;             else &amp;#10;&#x9;&#x9;&#x9;             if substr(ln_rounded_prem,length(ln_rounded_prem),1) = 0 then&amp;#10;&#x9;&#x9;&#x9;       &#x9;        ln_prem := substr(ln_rounded_prem,1,length(ln_rounded_prem)-1)||'0'; &amp;#10;&#x9;&#x9;&#x9;             elsif substr(ln_rounded_prem,length(ln_rounded_prem),1) > 0 and&amp;#10;&#x9;&#x9;        &#x9;        substr(ln_rounded_prem,length(ln_rounded_prem),1) &lt;= 5 then&amp;#10;&#x9;&#x9;                  ln_prem := substr(ln_rounded_prem,1,length(ln_rounded_prem)-1)||'5';&amp;#10;&#x9;&#x9;&#x9;&#x9;           elsif substr(ln_rounded_prem,length(ln_rounded_prem),1) > 5  and &amp;#10;&#x9;&#x9;&#x9;       &#x9;        substr(ln_rounded_prem,length(ln_rounded_prem),1) &lt;= 9 and&amp;#10;&#x9;&#x9;&#x9;       &#x9;        Ln_round_digits &lt;> 1 then    &amp;#10;&#x9;&#x9;&#x9;       &#x9;        ln_prem := substr(ln_rounded_prem,1,length(ln_rounded_prem)-2)||substr(ln_rounded_prem,length(ln_rounded_prem)-1,1)+1||'0'; &amp;#10;&#x9;&#x9;&#x9;       &#x9;     elsif substr(ln_rounded_prem,length(ln_rounded_prem),1) > 5  and &amp;#10;&#x9;&#x9;&#x9;       &#x9;        substr(ln_rounded_prem,length(ln_rounded_prem),1) &lt;= 9 and&amp;#10;&#x9;&#x9;&#x9;       &#x9;        Ln_round_digits = 1 then&amp;#10;&#x9;&#x9;&#x9;       &#x9;        ln_first_value := floor(ln_first_value)+ 1;&amp;#10;&#x9;&#x9;&#x9;       &#x9;        ln_prem := 0;       &#x9;  &amp;#10;&#x9;&#x9;&#x9;       &#x9;     end if;&amp;#10;&#x9;&#x9;&#x9;       &#x9; end if;   &amp;#10;&#x9;          End if;&amp;#10;&#x9;          If ln_round_to =  0  and lv_round_method = 'F' then     &amp;#10;&#x9;             ln_prem := substr(ln_rounded_prem,1,length(ln_rounded_prem)-1)  ||'0'; &amp;#10;&#x9;          End if;&amp;#10;&#x9;    &amp;#10;&#x9;          If ln_round_to =  0  and lv_round_method = 'C' then     &amp;#10;&#x9;             if lv_temp = 'ZERO'&#x9; then&amp;#10;&#x9;                ln_prem := substr(ln_rounded_prem,1,length(ln_rounded_prem)-1)||'0'; &#x9;&amp;#10;&#x9;             else   &amp;#10;&#x9;&#x9;&#x9;             if substr(ln_rounded_prem,length(ln_rounded_prem),1) = 0  and ln_round_digits &lt;> 1 then&amp;#10;&#x9;&#x9;&#x9;       &#x9;        ln_prem := substr(ln_rounded_prem,1,length(ln_rounded_prem)-1)||'0'; &amp;#10;&#x9;&#x9;&#x9;             elsif substr(ln_rounded_prem,length(ln_rounded_prem),1) > 0  and &amp;#10;&#x9;&#x9;&#x9;       &#x9;        substr(ln_rounded_prem,length(ln_rounded_prem),1) &lt;= 9 and&amp;#10;&#x9;&#x9;&#x9;       &#x9;        Ln_round_digits &lt;> 1 then    &amp;#10;&#x9;&#x9;&#x9;       &#x9;        ln_prem := substr(ln_rounded_prem,1,length(ln_rounded_prem)-2)||substr(ln_rounded_prem,length(ln_rounded_prem)-1,1)+1||'0'; &amp;#10;&#x9;&#x9;&#x9;       &#x9;     elsif substr(ln_rounded_prem,length(ln_rounded_prem),1) > 0  and &amp;#10;&#x9;&#x9;&#x9;       &#x9;        substr(ln_rounded_prem,length(ln_rounded_prem),1) &lt;= 9 and&amp;#10;&#x9;&#x9;&#x9;       &#x9;        Ln_round_digits = 1 then&amp;#10;&#x9;&#x9;&#x9;       &#x9;        ln_first_value := floor(ln_first_value)+ 1;&amp;#10;&#x9;&#x9;&#x9;       &#x9;        ln_prem := 0;       &#x9;  &amp;#10;&#x9;&#x9;&#x9;       &#x9;     end if;&#x9;  &amp;#10;               end if;&#x9;&#x9;  &amp;#10;&#x9;          End if;&amp;#10;&#x9;          ln_prem := floor(ln_first_value)||'.'||ln_prem;&amp;#10;&#x9;       elsif lv_decimal_side = 'B' and lv_round_method in ('F','C') &amp;#10;&#x9;          and lv_first_cut_digit_check = 'N' and Ln_round_digits &lt;> 0 then&amp;#10;&#x9;          If ln_round_to =  0  and lv_round_method = 'C' then&amp;#10;         &#x9;     ln_temp := substr(ln_rounded_prem,(length(ln_rounded_prem)-ln_round_digits+1),1);&amp;#10;         &#x9;     if ln_temp >= 1 and ln_temp &lt;= 4 then&amp;#10;         &#x9;  &#x9;    ln_temp := ln_temp + 5;&amp;#10;         &#x9;     end if;&amp;#10;         &#x9;     ln_prem := substr(ln_rounded_prem,1,length(ln_rounded_prem)-ln_round_digits)||ln_temp||substr(ln_rounded_prem,length(ln_rounded_prem)-ln_round_digits+2,ln_round_digits-1);&amp;#10;         &#x9;     ln_prem := round(ln_prem,'-'||ln_round_digits);&amp;#10;            end if;&#x9;  &amp;#10;            If ln_round_to =  0  and lv_round_method = 'F' then&amp;#10;         &#x9;     ln_temp := substr(ln_rounded_prem,(length(ln_rounded_prem)-ln_round_digits+1),1);&amp;#10;         &#x9;     if ln_temp >= 5 and ln_temp &lt;= 9 then&amp;#10;         &#x9;  &#x9;    ln_temp := ln_temp - 5;&amp;#10;         &#x9;     end if;&amp;#10;         &#x9;     ln_prem := substr(ln_rounded_prem,1,length(ln_rounded_prem)-ln_round_digits)||ln_temp||substr(ln_rounded_prem,length(ln_rounded_prem)-ln_round_digits+2,ln_round_digits-1);&amp;#10;         &#x9;     ln_prem := round(ln_prem,'-'||ln_round_digits);&amp;#10;            end if;&amp;#10;         &amp;#10;            If ln_round_to = 5   and lv_round_method = 'C' then&amp;#10;         &#x9;     ln_temp := substr(ln_rounded_prem,(length(ln_rounded_prem)-ln_round_digits+1),1);&amp;#10;         &#x9;     if ln_temp >= 1 and ln_temp &lt;= 5 then&amp;#10;         &#x9;  &#x9;    ln_temp := 5;&amp;#10;         &#x9;  &#x9;    ln_prem := substr(ln_rounded_prem,1,length(ln_rounded_prem)-ln_round_digits)||ln_temp;&amp;#10;         &#x9;     elsif ln_temp >= 6 and ln_temp &lt;= 9 then&amp;#10;         &#x9;  &#x9;    ln_temp := 0;&amp;#10;         &#x9;  &#x9;    ln_prem := substr(ln_rounded_prem,1,length(ln_rounded_prem)-ln_round_digits)+1||ln_temp;&amp;#10;         &#x9;  &#x9;    if ln_prem = 0 then&amp;#10;         &#x9;  &#x9;    &#x9; ln_prem := 10;&amp;#10;         &#x9;  &#x9;    &#x9; ln_rounded_prem := ln_rounded_prem || 1;&amp;#10;         &#x9;  &#x9;    end if;&#x9; &amp;#10;         &#x9;     elsif ln_temp = 0 then&amp;#10;         &#x9;  &#x9;    ln_temp := 0;&amp;#10;         &#x9;  &#x9;    ln_prem := substr(ln_rounded_prem,1,length(ln_rounded_prem)-ln_round_digits)||ln_temp;&amp;#10;         &#x9;     end if;&amp;#10;         &#x9;     ln_prem := rpad(ln_prem,length(ln_rounded_prem),0);&amp;#10;            end if;&amp;#10;         &amp;#10;            If ln_round_to = 5   and lv_round_method = 'F' then&amp;#10;         &#x9;     ln_temp := substr(ln_rounded_prem,(length(ln_rounded_prem)-ln_round_digits+1),1);&amp;#10;         &#x9;     if ln_temp >= 0 and ln_temp &lt;= 4 then&amp;#10;         &#x9;  &#x9;    ln_temp := 0;&amp;#10;         &#x9;  &#x9;    ln_prem := substr(ln_rounded_prem,1,length(ln_rounded_prem)-ln_round_digits)||ln_temp;&amp;#10;         &#x9;     elsif ln_temp >= 5 and ln_temp &lt;= 9 then&amp;#10;         &#x9;  &#x9;    ln_temp := 5;&amp;#10;         &#x9;  &#x9;    ln_prem := substr(ln_rounded_prem,1,length(ln_rounded_prem)-ln_round_digits)||ln_temp;&amp;#10;         &#x9;     end if;&#x9; &amp;#10;         &#x9;     ln_prem := rpad(ln_prem,length(ln_rounded_prem),0);&amp;#10;         &#x9;  end if;&amp;#10;         elsif lv_round_method = 'R' and ln_round_to = 0 and lv_first_cut_digit_check = 'N' then&amp;#10;      &#x9; &#x9;  if lv_decimal_side = 'A' then&amp;#10;      &#x9; &#x9;     ln_temp := nvl(substr(ln_rounded_prem,ln_round_digits,1),0);&amp;#10;      &#x9; &#x9;     if lv_temp = 'ZERO'&#x9; then&amp;#10;&#x9;                ln_prem := 0;&amp;#10;&#x9;             else&amp;#10;&#x9;&#x9;      &#x9;       if ln_temp in (0,1,2,3,4) then&amp;#10;&#x9;&#x9;      &#x9; &#x9;        ln_prem :=substr(ln_rounded_prem,1,ln_round_digits-1)||'0';&amp;#10;&#x9;&#x9;      &#x9;       elsif ln_temp in (5,6,7,8,9) and ln_round_digits &lt;> 1 then&amp;#10;&#x9;&#x9;      &#x9; &#x9;        ln_prem :=substr(ln_rounded_prem,1,ln_round_digits-1)+1||'0';&amp;#10;&#x9;&#x9;      &#x9;       elsif ln_temp in (5,6,7,8,9) and ln_round_digits =1 then   &amp;#10;&#x9;&#x9;      &#x9;       &#x9;  ln_prem := 0;&amp;#10;&#x9;&#x9;      &#x9;       &#x9;  ln_first_value := floor(ln_first_value) + 1;&amp;#10;&#x9;&#x9;      &#x9;       end if;&amp;#10;&#x9;&#x9;      &#x9;   end if;    &amp;#10;      &#x9;       ln_prem := floor(ln_first_value)||'.'||ln_prem;&amp;#10;            elsif lv_decimal_side = 'B' and ln_round_digits &lt;> 0 then&amp;#10;      &#x9;       ln_temp := substr(ln_rounded_prem,(length(ln_rounded_prem)-ln_round_digits+1),1);&#x9;&amp;#10;      &#x9;       if ln_temp in (0,1,2,3,4) then&amp;#10;      &#x9; &#x9;        ln_prem :=substr(ln_rounded_prem,1,length(ln_rounded_prem)-ln_round_digits)||'0';&amp;#10;      &#x9;       elsif ln_temp in (5,6,7,8,9) and ln_round_digits &lt;> 0 then&amp;#10;      &#x9; &#x9;        ln_prem :=substr(ln_rounded_prem,1,length(ln_rounded_prem)-ln_round_digits)+1||'0';&amp;#10;      &#x9; &#x9;        if ln_prem = 0 then&amp;#10;         &#x9;  &#x9;    &#x9; ln_prem := 10;&amp;#10;         &#x9;  &#x9;    &#x9; ln_rounded_prem := ln_rounded_prem || 1;&amp;#10;         &#x9;  &#x9;    end if;&#x9;&amp;#10;      &#x9;       end if;&amp;#10;      &#x9;       ln_prem := rpad(ln_prem,length(ln_rounded_prem),0);&amp;#10;      &#x9;    elsif lv_decimal_side = 'B' and ln_round_digits = 0 then&amp;#10;               ln_prem := ln_rounded_prem;&amp;#10;            end if;       &#x9; &#x9;&amp;#10;            &amp;#10;         elsif lv_round_method = 'R' and ln_round_to = 5 and lv_first_cut_digit_check = 'N' then&amp;#10;      &#x9; &#x9;  if lv_decimal_side = 'A' then&amp;#10;      &#x9; &#x9;  &#x9; if lv_temp = 'ZERO'&#x9; then&amp;#10;&#x9;                ln_prem := substr(ln_rounded_prem,1,length(ln_rounded_prem)-1)||'0'; &#x9;&amp;#10;&#x9;             else &amp;#10;&#x9;&#x9;      &#x9; &#x9;     ln_temp := nvl(substr(ln_rounded_prem,ln_round_digits,1),0);&amp;#10;&#x9;&#x9;      &#x9;       if ln_temp in (0,1,2) then&amp;#10;&#x9;&#x9;      &#x9; &#x9;        ln_prem :=substr(ln_rounded_prem,1,ln_round_digits-1)||'0';&amp;#10;&#x9;&#x9;      &#x9;       elsif ln_temp in (3,4,5,6,7) then &amp;#10;&#x9;&#x9;      &#x9; &#x9;        ln_prem :=substr(ln_rounded_prem,1,ln_round_digits-1)||'5';&amp;#10;&#x9;&#x9;      &#x9;       elsif ln_temp in (8,9) and ln_round_digits &lt;> 1 then&amp;#10;&#x9;&#x9;      &#x9; &#x9;        ln_prem :=substr(ln_rounded_prem,1,ln_round_digits-1)+1;&amp;#10;&#x9;&#x9;      &#x9; &#x9;        ln_prem := rpad(ln_prem,length(ln_prem+1),0);&amp;#10;&#x9;&#x9;      &#x9;       elsif ln_temp in (8,9) and ln_round_digits =1 then   &amp;#10;&#x9;&#x9;      &#x9;       &#x9;  ln_prem := 0;&amp;#10;&#x9;&#x9;      &#x9;       &#x9;  ln_first_value := floor(ln_first_value) + 1;&amp;#10;&#x9;&#x9;      &#x9;       end if;   &amp;#10;&#x9;&#x9;      &#x9;   end if;   &amp;#10;&#x9;&#x9;      &#x9;   ln_prem := floor(ln_first_value)||'.'||ln_prem;&amp;#10;            elsif lv_decimal_side = 'B' and ln_round_digits &lt;> 0 then&amp;#10;      &#x9;       ln_temp := substr(ln_rounded_prem,(length(ln_rounded_prem)-ln_round_digits+1),1);&#x9;&amp;#10;      &#x9;       if ln_temp in (0,1,2) then&amp;#10;      &#x9; &#x9;        ln_prem :=substr(ln_rounded_prem,1,length(ln_rounded_prem)-ln_round_digits)||'0';&amp;#10;      &#x9;       elsif ln_temp in (3,4,5,6,7) then &amp;#10;      &#x9; &#x9;        ln_prem :=substr(ln_rounded_prem,1,length(ln_rounded_prem)-ln_round_digits)||'5';&amp;#10;      &#x9;       elsif ln_temp in (8,9) and ln_round_digits &lt;> 0 then&amp;#10;      &#x9; &#x9;        ln_prem :=substr(ln_rounded_prem,1,length(ln_rounded_prem)-ln_round_digits)+1||'0';&amp;#10;      &#x9; &#x9;        if ln_prem = 0 then&amp;#10;         &#x9;  &#x9;    &#x9; ln_prem := 10;&amp;#10;         &#x9;  &#x9;    &#x9; ln_rounded_prem := ln_rounded_prem || 1;&amp;#10;         &#x9;  &#x9;    end if;&#x9;&amp;#10;      &#x9;       end if;&amp;#10;      &#x9;       ln_prem := rpad(ln_prem,length(ln_rounded_prem),0);&amp;#10;      &#x9;    elsif lv_decimal_side = 'B' and ln_round_digits = 0 then&amp;#10;               ln_prem := ln_rounded_prem;&amp;#10;            end if;       &#x9; &amp;#10;         End if;&amp;#10;       end if;&amp;#10;&#x9; end if;   &amp;#10;   RETURN ln_prem ;&amp;#10;End;   "/>
      <Window Name="WINDOW1" Width="360" Height="324"/>
   </FormModule>
</Module>

【问题讨论】:

  • 您说要删除不需要的数据。不需要什么数据?如果你有这个 xml 对象,你想从中得到什么以及以什么格式?你想把它保存在xml中吗?将其更改为字典或数据列表,然后插入某处?
  • 我基本上只需要物品的所有价值。比如 改为: BLOCK2 true 9 135 ,格式可以是文本。我在搜索部分没有太多经验。最后我想查询这些字符串。我的挑战是我不确定每个标签中有多少属性以及它们的属性是什么(XML 属性)。
  • 任何不是根的东西都可以被认为是一个“项目”。你怎么知道某物是不是物品? FormModule 里面有什么东西吗?任何带有标签Item的东西?
  • Oracle表单包含几个部分,基本上我需要提取标签内的所有内容,这意味着“FormModule”,“Coordinate”,“Block”,“Item”,“Trigger”的所有属性",,"Canvas ","ProgramUnit " 和 "Window " 应该解析和提取。(只是它们的值)

标签: python xml oracleforms


【解决方案1】:

好吧,根据我从你所说的话中收集到的信息。这是将抓取所有子项并仅提取其值的代码。它将这些值转换为添加到列表中的单个字符串。找到所有子元素后返回列表。我不知道你对编码有多流利,但这被称为递归函数。它一直在调用自己,直到它没有更多的工作要做。

import xml.etree.ElementTree as ET

xml_items = []

root = ET.parse('data.xml').getroot()[0]

def get_attribs(element, items=None):
    items = items if items is not None else []

    items.append(' '.join([v for v in element.attrib.values()]))

    for child in element:
        get_attribs(child, items)

    return items

get_attribs(root)

结果

['TEST true MODULE1 DEFAULT&amp;SMARTBAR WINDOW1', '5 true Real 14 Point', 'BLOCK2 true 9 135', 'ROUND_RULE round rule 143 110 true 45 11 1 CANVAS5 14', ...]

【讨论】:

    猜你喜欢
    • 2011-10-11
    • 1970-01-01
    • 2021-09-19
    • 2011-04-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-05
    相关资源
    最近更新 更多