我試圖刪除這個字符串的第二部分(第二塊)刪除JavaScript的不工作
<resourceDescriptor name="report_mongodb_new_basic" wsType="reportUnit" uriString="/reports/samples/report_mongodb_new_basic" isNew="false">
<label><![CDATA[report mongodb new basic]]></label>
<description><![CDATA[test 3]]></description>
<creationDate>1330693884348</creationDate>
<resourceProperty name="PROP_RESOURCE_TYPE">
<value><![CDATA[com.jaspersoft.jasperserver.api.metadata.jasperreports.domain.ReportUnit]]></value>
</resourceProperty>
<resourceProperty name="PROP_PARENT_FOLDER">
<value><![CDATA[/reports/samples]]></value>
</resourceProperty>
<resourceProperty name="PROP_VERSION">
<value><![CDATA[0]]></value>
</resourceProperty>
<resourceProperty name="PROP_RU_ALWAYS_PROPMT_CONTROLS">
<value><![CDATA[false]]></value>
</resourceProperty>
<resourceProperty name="PROP_RU_CONTROLS_LAYOUT">
<value><![CDATA[1]]></value>
</resourceProperty>
<resourceProperty name="PROP_RU_REPORT_RENDERING_VIEW">
<value><![CDATA[]]></value>
</resourceProperty>
<resourceDescriptor wsType="datasource" isNew="false">
<resourceProperty name="PROP_REFERENCE_URI">
<value><![CDATA[/datasources/MongoDB]]></value>
</resourceProperty>
<resourceProperty name="PROP_IS_REFERENCE">
<value><![CDATA[true]]></value>
</resourceProperty>
<resourceDescriptor name="report_mongodb_new_basic_" wsType="jrxml" uriString="/reports/samples/report_mongodb_new_basic_files/report_mongodb_new_basic_" isNew="false">
<label><![CDATA[report mongodb new basic]]></label>
<creationDate>1330693884348</creationDate>
<resourceProperty name="PROP_RESOURCE_TYPE">
<value><![CDATA[com.jaspersoft.jasperserver.api.metadata.common.domain.FileResource]]></value>
</resourceProperty>
<resourceProperty name="PROP_PARENT_FOLDER">
<value><![CDATA[/reports/samples/report_mongodb_new_basic_files]]></value>
</resourceProperty>
<resourceProperty name="PROP_VERSION">
<value><![CDATA[0]]></value>
</resourceProperty>
<resourceProperty name="PROP_IS_REFERENCE">
<value><![CDATA[false]]></value>
</resourceProperty>
<resourceProperty name="PROP_HAS_DATA">
<value><![CDATA[true]]></value>
</resourceProperty>
<resourceProperty name="PROP_ATTACHMENT_ID">
<value><![CDATA[attachment]]></value>
</resourceProperty>
<resourceProperty name="PROP_RU_IS_MAIN_REPORT">
<value><![CDATA[true]]></value>
</resourceProperty>
</resourceDescriptor>
字符串的一部分,我只是想第一阻止 (From : <resourceDescriptor to </resourceDescriptor>
我目前這樣做,但它不工作:
var sbody = a.body; //sbody is a String
sbody.split("</resourceDescriptor>").pop();
console.log(sbody);
結果改變什麼(CONSOLE.LOG是它的NodeJS的打印件) OR
sbody.substring(sbody.indexOf("<resourceDescriptor>") + 1, sbody.indexOf("</resourceDescriptor>"));
console.log(sbody);
結果改變也沒有,爲什麼呢?
由於
謝謝! ,FYI實際上'pop'不工作,但是子串我有第一個塊,但不是它的最後部分( resourceDescriptor> ) – Louis 2012-03-07 10:47:05
這是工作(但醜陋):'VAR nbody = sbody.substring(sbody .indexOf( 「」)+ 1,sbody.indexOf( 「 resourceDescriptor>」)+ 21);' –
Louis
2012-03-07 10:56:02