按根名称对 XML 内容进行分组

问题描述

由于我的 XML 创建步骤(Service WSDL File Step by Step Processing),我得到了这种 XML 语法:

<auth>
    <appKey>ABCD567</appKey>
</auth>
<auth>
    <appSecret>456TYUU</appSecret>
</auth>

主机服务不接受它,响应一个'auth'元素丢失>,它接受这个:

<auth>
    <appKey>ABCD567</appKey>
    <appSecret>456TYUU</appSecret>
</auth>

我如何通过 XML 处理代码实现(在创建 XML 后将相同的根与不同的元素分组 - 无法更改创建过程)这种语法。

部分真实代码如下:

<env:Envelope
    xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
    <env:Header/>
    <soapenv:Body>
        <sch:GetCategoryAttributesRequest>
            <auth>
                <appKey>***</appKey>
                <appSecret>***</appSecret>
            </auth>
            <categoryId>1002306</categoryId>
            <pagingData>
                <currentPage>0</currentPage>
                <pageSize>100</pageSize>
            </pagingData>
            <attributeList>
                <attribute>
                    <id>354189900</id>
                </attribute>
                <attribute>
                    <mandatory>true</mandatory>
                </attribute>
            </attributeList>
        </sch:GetCategoryAttributesRequest>
    </soapenv:Body>
</soapenv:Envelope>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)