同事,找不到我的问题的决定......
这是我的代码,它将SngtrSt
元素添加到Envlp
:
SupplementaryDataEnvelope1 supplementaryDataEnvelope1 = new SupplementaryDataEnvelope1();
//Adding SplmtryData
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
org.w3c.dom.Document doc = docBuilder.newDocument();
//doc.setDocumentURI("urn:iso:std:iso:20022:tech:xsd:camt.060.001.03");
Element sngtrStElement = doc.createElement("SngtrSt");
sngtrStElement.setTextContent(TranConstants.SNGTR_ST_VALUE);
//sngtrStElement.removeAttributeNS("urn:iso:std:iso:20022:tech:xsd:camt.060.001.03", "xmlns");
supplementaryDataEnvelope1.setAny(sngtrStElement);
结果是:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.060.001.03">
<AcctRptgReq>
...
<SplmtryData>
<Envlp>
<SngtrSt xmlns="" xmlns:ns2="urn:iso:std:iso:20022:tech:xsd:camt.060.001.03"> </SngtrSt>
</Envlp>
</SplmtryData>
</AcctRptgReq>
</Document>
如何避免将字符串xmlns="" xmlns:ns2="urn:iso:std:iso:20022:tech:xsd:camt.060.001.03"
添加到SngtrSt
元素(从元素中删除xmlns及其值)?