Android使用DOM解析XML文件并动态生成XML文件内容

一、asssts目录下xml.xml文件

<?xml version="1.0" encoding="gbk"?>
<dmodule>
    <identAndStatusSection>
        <dmAddress>
            <dmIdent>
                <language countryIsoCode="CN" languageIsoCode="zh" />
                <issueInfo issueNumber="A" />
            </dmIdent>
            <dmAddressItems>
                <issueDate day="09" month="05" year="2023" />
                <dmTitle>
                    <techName flag="0">测试</techName>
                    <infoName />
                </dmTitle>
            </dmAddressItems>
        </dmAddress>
        <dmStatus>
            <security securityClassification="" />
            <responsiblePartnerCompany />
            <originator />
        </dmStatus>
    </identAndStatusSection>
    <content>
        <procedure>
            <mainProcedure>
                <complexProceduralStep id="ID_555292415432_335823572473">
                    <title>工卡</title>
                    <para id="ID_923340155742_736007254570">段落一</para>
                    <para id="ID_459845896577_375694015761">段落二</para>
                    <para id="ID_278292653616_774219508515" />
                    <para id="ID_409056249074_272650145925">段落四</para>
                    <backfillvalue id="ID_976951391668_892627530730" statusType="故检">
                        <backfillDesc>过去</backfillDesc>
                        <dateType>
                            <data />
                            <time />
                        </dateType>
                    </backfillvalue>
                    <backfillvalue id="ID_104390905937_526617690687" statusType="故检">
                        <backfillDesc></backfillDesc>
                        <dateType>
                            <data />
                        </dateType>
                    </backfillvalue>
                    <backfillvalue id="ID_215612338390_395147222792" statusType="故检">
                        <backfillDesc>将来</backfillDesc>
                        <dateType>
                            <data />
                            <time />
                        </dateType>
                    </backfillvalue>
                    <complexProceduralStep id="ID_612841033143_683289984473">
                        <title>工步一</title>
                        <para id="ID_733485024887_550917605636">段落</para>
                        <backfillvalue id="ID_742752832360_183918928262" statusType="故检">
                            <backfillDesc></backfillDesc>
                            <text textType="short" />
                        </backfillvalue>
                        <backfillvalue id="ID_635135996620_294568416895" statusType="故检">
                            <backfillDesc>备注</backfillDesc>
                            <text maxLength="5" textType="short" />
                        </backfillvalue>
                        <backfillvalue id="ID_112047505984_686786890285" statusType="故检">
                            <backfillDesc></backfillDesc>
                            <text textType="long" />
                        </backfillvalue>
                    </complexProceduralStep>
                    <complexProceduralStep id="ID_660821468569_387697003083">
                        <title>工步二</title>
                        <para id="ID_530755591113_748297208221">段落</para>
                        <backfillvalue id="ID_492416651220_700172579847" statusType="故检">
                            <backfillDesc></backfillDesc>
                            <checkbox>同意</checkbox>
                        </backfillvalue>
                        <backfillvalue id="ID_629123128484_770693675614" statusType="故检">
                            <backfillDesc>性别</backfillDesc>
                            <checkbox>男</checkbox>
                            <checkbox>女</checkbox>
                        </backfillvalue>
                        <backfillvalue id="ID_917651352472_738172412849" statusType="故检">
                            <backfillDesc>爱好</backfillDesc>
                            <checkbox>运动</checkbox>
                            <checkbox>游戏</checkbox>
                            <checkbox>音乐</checkbox>
                        </backfillvalue>
                        <complexProceduralStep id="ID_618508407613_318769715726">
                            <title>拆解</title>
                            <para id="ID_133643329609_265100201126">段落</para>
                            <backfillvalue id="ID_351545945042_782881733728" statusType="故检">
                                <backfillDesc>范围</backfillDesc>
                                <numericMore>
                                    <numericTwo andOr="and" booleanOperation="greaterThan">
                                        <numericValueAlone>0</numericValueAlone>
                                        <numericValueAlone>10</numericValueAlone>
                                    </numericTwo>
                                </numericMore>
                            </backfillvalue>
                            <backfillvalue id="ID_981290129711_849704570136" statusType="故检">
                                <backfillDesc></backfillDesc>
                                <numericMore>
                                    <numericTwo andOr="and" booleanOperation="notEqual">
                                        <numericValueAlone>5</numericValueAlone>
                                        <numericValueAlone>10</numericValueAlone>
                                        <numericValueAlone>15</numericValueAlone>
                                    </numericTwo>
                                </numericMore>
                            </backfillvalue>
                            <backfillvalue id="ID_867711359168_444036011118" statusType="故检">
                                <backfillDesc>阈值</backfillDesc>
                                <numericMore>
                                    <numericTwo andOr="and" booleanOperation="lessThan">
                                        <numericValueAlone>2</numericValueAlone>
                                        <numericValueAlone>5</numericValueAlone>
                                        <numericValueAlone>8</numericValueAlone>
                                    </numericTwo>
                                </numericMore>
                            </backfillvalue>
                        </complexProceduralStep>
                    </complexProceduralStep>
                    <complexProceduralStep id="ID_927647629985_139172560070">
                        <title>工步三</title>
                        <para id="ID_751828468870_476183717604" />
                        <backfillvalue id="ID_500129662454_936935039236" statusType="故检">
                            <backfillDesc></backfillDesc>
                        </backfillvalue>
                        <backfillvalue id="ID_665241134585_587279943283" statusType="故检">
                            <backfillDesc>嘿嘿</backfillDesc>
                        </backfillvalue>
                        <complexProceduralStep id="ID_158451685216_416514249518">
                            <title>清洗</title>
                            <para id="ID_380563274258_118835580535">段落</para>
                            <backfillvalue id="ID_472359934356_765566902002" statusType="故检">
                                <backfillDesc>无验证值</backfillDesc>
                                <numeric numericType="single" />
                            </backfillvalue>
                            <backfillvalue id="ID_294495831243_974503772565" statusType="故检">
                                <backfillDesc></backfillDesc>
                                <numeric numericType="single">
                                    <numericValue andOr="and" booleanOperation="lessThan">0</numericValue>
                                </numeric>
                            </backfillvalue>
                            <backfillvalue id="ID_858602679334_835727104916" statusType="故检">
                                <backfillDesc>数字</backfillDesc>
                                <numeric numericType="single">
                                    <numericValue andOr="and" booleanOperation="lessThan">120</numericValue>
                                    <numericValue andOr="and" booleanOperation="greaterThan">100</numericValue>
                                </numeric>
                            </backfillvalue>
                            <backfillvalue id="ID_804131829179_401760787377" statusType="故检">
                                <backfillDesc>范围</backfillDesc>
                                <numeric numericType="range">
                                    <numericValue andOr="and" booleanOperation="greaterThan">10</numericValue>
                                    <numericValue andOr="and" booleanOperation="lessThan">50</numericValue>
                                </numeric>
                            </backfillvalue>
                        </complexProceduralStep>
                        <complexProceduralStep id="ID_453025892144_962426130193">
                            <title>排故</title>
                            <para id="ID_331255954457_819634620565">段落</para>
                            <backfillvalue id="ID_963196400552_704713189275" statusType="故检">
                                <backfillDesc></backfillDesc>
                                <rangNumeric numericType="single">
                                    <baseValue>10</baseValue>
                                    <offsetValue>5</offsetValue>
                                </rangNumeric>
                            </backfillvalue>
                            <backfillvalue id="ID_569828050443_318050313741" statusType="故检">
                                <backfillDesc>偏移量</backfillDesc>
                                <rangNumeric numericType="single">
                                    <baseValue>100</baseValue>
                                    <offsetValue>50</offsetValue>
                                </rangNumeric>
                            </backfillvalue>
                        </complexProceduralStep>
                    </complexProceduralStep>
                </complexProceduralStep>
            </mainProcedure>
        </procedure>
    </content>
</dmodule>

二、工步数据实体类ProceduralStep

package com.example.analysisxml;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 工步数据实体类
 */
public class ProceduralStep {

    // 工步ID
    public String complexProceduralStep_id;

    // 标题
    public String title;

    // 段落
    public List<Map> para = new ArrayList<>();

    // 回填数据
    public List<Map> back_fill_value = new ArrayList<>();

    // 复杂工步
    public List<ProceduralStep> step_list = new ArrayList<>();

    public String getComplexProceduralStep_id() {
        return complexProceduralStep_id;
    }

    public void setComplexProceduralStep_i
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Qxnedy

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值