现在我正在开发一个已经构建的应用程序,其中的功能看起来像这样
void postOutgoing(IXMLDOMDocument2Ptr &document)
{
//getting XML from base document
MSXML2::IXMLDOMElementPtr element = document->GetdocumentElement();
//_bstr_t elementBaseName = element->GetbaseName();
string test=element->Getxml();
int start=(test.find("LoadBridgeXml"))+13+1;
int end=test.find("LoadBridgeXml",start);
string test2=test.substr(start,(end-start-2));
replaceAll(test2,">",">");
replaceAll(test2,"<","<");
}
在执行(string test = element-> Getxml();)的调试期间,我得到了这个xml,并传递给了string变量test
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<LoadBridgeXml>
<xmlRequest>
<Header/>
<XmlBridge>
<extension fieldNo="1505" value="0021"/>
<extension fieldNo="20104" value=""/>
</XmlBridge>
</xmlRequest>
</LoadBridgeXml>
</soap:Body>
</soap:Envelope>
我想替换标记“ LoadBridgeXml”的内部XML,并使XML看起来像这样
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<LoadBridgeXml>
<xmlRequest>
<Header/>
<XmlBridge>
<extension fieldNo="1505" value="0021"/>
<extension fieldNo="20104" value=""/>
</XmlBridge>
</xmlRequest>
</LoadBridgeXml>
</soap:Body>
</soap:Envelope>
是否可以仅替换<>符号或以任何方式用字符串替换LoadBridgeXml的内部XML