Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Scala从内部子级删除xml元素_Xml_Scala_Nodes - Fatal编程技术网

Scala从内部子级删除xml元素

Scala从内部子级删除xml元素,xml,scala,nodes,Xml,Scala,Nodes,我试图使用Scala xml从xml中删除一个子元素。我花了太多时间来弄清楚如何删除子元素,但没有任何效果。请帮忙 输入XML: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <s

我试图使用Scala xml从xml中删除一个子元素。我花了太多时间来弄清楚如何删除子元素,但没有任何效果。请帮忙

输入XML:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Header>
        <Header xmlns="http://abcde.com/reportserv">
            <RequestId>kfgndfgldfknbdfbd</RequestId>
            <ResponseTime>13.98</ResponseTime>
        </Header>
    </soap:Header>
    <soap:Body>
        <DetailResponse xmlns="http://abcde.com/reportserv">
            <DetailResult>
                <Detail>
                    <Domain>Not Available</Domain>
                    <Name />
                    <Email />
                    <PostalCode />
                </Detail>
                <Detail>
                    <Domain>Available</Domain>
                    <Name />
                    <Email />
                    <Phone>143-234-1234</Phone>
                    <PostalCode />
                </Detail>
                <Detail>
                    <Domain>Not Available</Domain>
                    <Name />
                    <Email>tp1@gmail.com</Email>
                    <Phone />
                    <PostalCode />
                </Detail>
            </DetailResult>
        </DetailResponse>
    </soap:Body>
</soap:Envelope>

如我所见,
deleteNodes
不会删除它们的节点。只能选择要删除的图元。类似的问题:正如我所看到的,
deleteNodes
不会删除它们的节点。只能选择要删除的图元。类似问题:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Header>
        <Header xmlns="http://abcde.com/reportserv">
            <RequestId>kfgndfgldfknbdfbd</RequestId>
            <ResponseTime>13.98</ResponseTime>
        </Header>
    </soap:Header>
    <soap:Body>
        <DetailResponse xmlns="http://abcde.com/reportserv">
            <DetailResult>
                <Detail>
                    <Domain>Not Available</Domain>
                    <Name />
                    <PostalCode />
                </Detail>
                <Detail>
                    <Domain>Available</Domain>
                    <Name />
                    <PostalCode />
                </Detail>
                <Detail>
                    <Domain>Not Available</Domain>
                    <Name />
                    <PostalCode />
                </Detail>
            </DetailResult>
        </DetailResponse>
    </soap:Body>
</soap:Envelope>
def deleteNodes(n: Elem, f: (Node) => Boolean) = {
  n.child.foldLeft(NodeSeq.Empty)((acc, elem) => if (f(elem)) acc else acc ++ elem)
}


var deleted_elements = person.copy(child = deleteNodes(person, (elem) => (elem.label=="Email"|| elem.label=="Phone")))