当前,我有一个带有括号和,
的有效载荷,用于分隔每行。这个想法是删除开头的[
和结尾的]
,以及中间的,
有什么主意吗?
[<?xml version="1.0" encoding="UTF-8"?><reserveCPE_Res xmlns="http://xmlns.oracle.com/Enterprise/Tools/schemas/reserveCPE_Res.VERSION_1" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><reserveCPE_Res_Part><t_reserve_res xmlns="http://xmlns.oracle.com/Enterprise/Tools/schemas/reserveCPE_Res_Part.VERSION_1" class="R"><T_SUCCESS_FLAG>N</T_SUCCESS_FLAG><ORDER_NO/><DESCR2000>Not available. (30000,8)</DESCR2000><t_reserve_array class="R"><T_CPE_TYPE>SDSTB</T_CPE_TYPE><T_CPE_MODEL/><T_CPE_TYPE_QTY>0</T_CPE_TYPE_QTY></t_reserve_array><t_reserve_array class="R"><T_CPE_TYPE>SDSTB</T_CPE_TYPE><T_CPE_MODEL/><T_CPE_TYPE_QTY>0</T_CPE_TYPE_QTY></t_reserve_array></t_reserve_res></reserveCPE_Res_Part></reserveCPE_Res>, <?xml version="1.0" encoding="UTF-8"?><reserveCPE_Res xmlns="http://xmlns.oracle.com/Enterprise/Tools/schemas/reserveCPE_Res.VERSION_1" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><reserveCPE_Res_Part><t_reserve_res xmlns="http://xmlns.oracle.com/Enterprise/Tools/schemas/reserveCPE_Res_Part.VERSION_1" class="R"><T_SUCCESS_FLAG>N</T_SUCCESS_FLAG><ORDER_NO/><DESCR2000>The Business Unit MARIO is not exist. (30000,4)</DESCR2000></t_reserve_res></reserveCPE_Res_Part></reserveCPE_Res>, <?xml version="1.0" encoding="UTF-8"?><reserveCPE_Res xmlns="http://xmlns.oracle.com/Enterprise/Tools/schemas/reserveCPE_Res.VERSION_1" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><reserveCPE_Res_Part><t_reserve_res xmlns="http://xmlns.oracle.com/Enterprise/Tools/schemas/reserveCPE_Res_Part.VERSION_1" class="R"><T_SUCCESS_FLAG>N</T_SUCCESS_FLAG><ORDER_NO/><DESCR2000>The Business Unit ERNES is not exist. (30000,4)</DESCR2000></t_reserve_res></reserveCPE_Res_Part></reserveCPE_Res>]
答案 0 :(得分:0)
我的评论太长了,无法在评论部分发布,因此请在此处发布。
这就是您的有效载荷的样子。
[<?xml version="1.0" encoding="UTF-8"?>
<reserveCPE_Res xmlns="http://xmlns.oracle.com/Enterprise/Tools/schemas/reserveCPE_Res.VERSION_1" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<reserveCPE_Res_Part>
<t_reserve_res xmlns="http://xmlns.oracle.com/Enterprise/Tools/schemas/reserveCPE_Res_Part.VERSION_1" class="R">
<T_SUCCESS_FLAG>N</T_SUCCESS_FLAG>
<ORDER_NO/>
<DESCR2000>Not available. (30000,8)</DESCR2000>
<t_reserve_array class="R">
<T_CPE_TYPE>SDSTB</T_CPE_TYPE>
<T_CPE_MODEL/>
<T_CPE_TYPE_QTY>0</T_CPE_TYPE_QTY>
</t_reserve_array>
<t_reserve_array class="R">
<T_CPE_TYPE>SDSTB</T_CPE_TYPE>
<T_CPE_MODEL/>
<T_CPE_TYPE_QTY>0</T_CPE_TYPE_QTY>
</t_reserve_array>
</t_reserve_res>
</reserveCPE_Res_Part>
</reserveCPE_Res>, <?xml version="1.0" encoding="UTF-8"?>
<reserveCPE_Res xmlns="http://xmlns.oracle.com/Enterprise/Tools/schemas/reserveCPE_Res.VERSION_1" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<reserveCPE_Res_Part>
<t_reserve_res xmlns="http://xmlns.oracle.com/Enterprise/Tools/schemas/reserveCPE_Res_Part.VERSION_1" class="R">
<T_SUCCESS_FLAG>N</T_SUCCESS_FLAG>
<ORDER_NO/>
<DESCR2000>The Business Unit MARIO is not exist. (30000,4)</DESCR2000>
</t_reserve_res>
</reserveCPE_Res_Part>
</reserveCPE_Res>, <?xml version="1.0" encoding="UTF-8"?>
<reserveCPE_Res xmlns="http://xmlns.oracle.com/Enterprise/Tools/schemas/reserveCPE_Res.VERSION_1" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<reserveCPE_Res_Part>
<t_reserve_res xmlns="http://xmlns.oracle.com/Enterprise/Tools/schemas/reserveCPE_Res_Part.VERSION_1" class="R">
<T_SUCCESS_FLAG>N</T_SUCCESS_FLAG>
<ORDER_NO/>
<DESCR2000>The Business Unit ERNES is not exist. (30000,4)</DESCR2000>
</t_reserve_res>
</reserveCPE_Res_Part>
</reserveCPE_Res>]
每个逗号后都有一个新的xml开始,因此除非您试图在xml中包含多行数据,否则您不能在一个xml下嵌入多个xml。
您要做的第一件事是将输入转换为格式正确的XML,而现在不是。看看您的有效载荷中所有这些, <?xml version="1.0" encoding="UTF-8"?>
都会变成垃圾。
以下代码将满足您的需求
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd">
<file:connector name="File" outputPattern="*" writeToDirectory="C:\Temp" readFromDirectory="C:\Users\satichen\Desktop\work\test" workDirectory="C:\Users\satichen\Desktop\saruku" autoDelete="false" streaming="true" validateConnections="true" doc:name="File"/>
<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8081" doc:name="HTTP Listener Configuration"/>
<flow name="playgroundFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
<set-payload value="#['[<?xml version="1.0" encoding="UTF-8"?><reserveCPE_Res xmlns="http://xmlns.oracle.com/Enterprise/Tools/schemas/reserveCPE_Res.VERSION_1" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><reserveCPE_Res_Part><t_reserve_res xmlns="http://xmlns.oracle.com/Enterprise/Tools/schemas/reserveCPE_Res_Part.VERSION_1" class="R"><T_SUCCESS_FLAG>N</T_SUCCESS_FLAG><ORDER_NO/><DESCR2000>Not available. (30000,8)</DESCR2000><t_reserve_array class="R"><T_CPE_TYPE>SDSTB</T_CPE_TYPE><T_CPE_MODEL/><T_CPE_TYPE_QTY>0</T_CPE_TYPE_QTY></t_reserve_array><t_reserve_array class="R"><T_CPE_TYPE>SDSTB</T_CPE_TYPE><T_CPE_MODEL/><T_CPE_TYPE_QTY>0</T_CPE_TYPE_QTY></t_reserve_array></t_reserve_res></reserveCPE_Res_Part></reserveCPE_Res>, <?xml version="1.0" encoding="UTF-8"?><reserveCPE_Res xmlns="http://xmlns.oracle.com/Enterprise/Tools/schemas/reserveCPE_Res.VERSION_1" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><reserveCPE_Res_Part><t_reserve_res xmlns="http://xmlns.oracle.com/Enterprise/Tools/schemas/reserveCPE_Res_Part.VERSION_1" class="R"><T_SUCCESS_FLAG>N</T_SUCCESS_FLAG><ORDER_NO/><DESCR2000>The Business Unit MARIO is not exist. (30000,4)</DESCR2000></t_reserve_res></reserveCPE_Res_Part></reserveCPE_Res>, <?xml version="1.0" encoding="UTF-8"?><reserveCPE_Res xmlns="http://xmlns.oracle.com/Enterprise/Tools/schemas/reserveCPE_Res.VERSION_1" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><reserveCPE_Res_Part><t_reserve_res xmlns="http://xmlns.oracle.com/Enterprise/Tools/schemas/reserveCPE_Res_Part.VERSION_1" class="R"><T_SUCCESS_FLAG>N</T_SUCCESS_FLAG><ORDER_NO/><DESCR2000>The Business Unit ERNES is not exist. (30000,4)</DESCR2000></t_reserve_res></reserveCPE_Res_Part></reserveCPE_Res>]']" mimeType="text/plain" doc:name="Set Payload"/>
<expression-component doc:name="remove quotes"><![CDATA[payload=payload.replace('[','');]]></expression-component>
<expression-component doc:name="remote quotes 2"><![CDATA[payload=payload.replace(']','');]]></expression-component>
<expression-component doc:name="Expression"><![CDATA[payload=payload.replace(',','');]]></expression-component>
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
</flow>
</mule>
并产生以下输出,但是如前所述,输出xml仍然是无效的xml,您可能希望重新查看有效载荷在源头的实际形成方式,并且可能需要更正它。
<?xml version="1.0" encoding="UTF-8"?>
<reserveCPE_Res xmlns="http://xmlns.oracle.com/Enterprise/Tools/schemas/reserveCPE_Res.VERSION_1" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<reserveCPE_Res_Part>
<t_reserve_res xmlns="http://xmlns.oracle.com/Enterprise/Tools/schemas/reserveCPE_Res_Part.VERSION_1" class="R">
<T_SUCCESS_FLAG>N</T_SUCCESS_FLAG>
<ORDER_NO/>
<DESCR2000>Not available. (300008)</DESCR2000>
<t_reserve_array class="R">
<T_CPE_TYPE>SDSTB</T_CPE_TYPE>
<T_CPE_MODEL/>
<T_CPE_TYPE_QTY>0</T_CPE_TYPE_QTY>
</t_reserve_array>
<t_reserve_array class="R">
<T_CPE_TYPE>SDSTB</T_CPE_TYPE>
<T_CPE_MODEL/>
<T_CPE_TYPE_QTY>0</T_CPE_TYPE_QTY>
</t_reserve_array>
</t_reserve_res>
</reserveCPE_Res_Part>
</reserveCPE_Res>
<?xml version="1.0" encoding="UTF-8"?>
<reserveCPE_Res xmlns="http://xmlns.oracle.com/Enterprise/Tools/schemas/reserveCPE_Res.VERSION_1" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<reserveCPE_Res_Part>
<t_reserve_res xmlns="http://xmlns.oracle.com/Enterprise/Tools/schemas/reserveCPE_Res_Part.VERSION_1" class="R">
<T_SUCCESS_FLAG>N</T_SUCCESS_FLAG>
<ORDER_NO/>
<DESCR2000>The Business Unit MARIO is not exist. (300004)</DESCR2000>
</t_reserve_res>
</reserveCPE_Res_Part>
</reserveCPE_Res>
<?xml version="1.0" encoding="UTF-8"?>
<reserveCPE_Res xmlns="http://xmlns.oracle.com/Enterprise/Tools/schemas/reserveCPE_Res.VERSION_1" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<reserveCPE_Res_Part>
<t_reserve_res xmlns="http://xmlns.oracle.com/Enterprise/Tools/schemas/reserveCPE_Res_Part.VERSION_1" class="R">
<T_SUCCESS_FLAG>N</T_SUCCESS_FLAG>
<ORDER_NO/>
<DESCR2000>The Business Unit ERNES is not exist. (300004)</DESCR2000>
</t_reserve_res>
</reserveCPE_Res_Part>
</reserveCPE_Res>