- XML code
<defaultSlice> <axes> <axis name="rows"> <hierarchy sort="unsorted"> <dimensionName>[Customer]</dimensionName> <hierarchyName>[Customer].[City]</hierarchyName> </hierarchy> </axis> <axis name="columns"> <hierarchy sort="asc"> <dimensionName>[Customer]</dimensionName> <hierarchyName>[Customer].[Country]</hierarchyName> <filter> <member><![CDATA[[Customer].[Country].&[#temp]]]></member> </filter> </hierarchy> <hierarchy> <dimensionName>[Measures]</dimensionName> <hierarchyName>[Measures]</hierarchyName> </hierarchy> </axis> <axis name="pages"/> </axes> <measures> <measure aggregation="sum">[Measures].[Internet Sales Amount]</measure> </measures> </defaultSlice>
我现在怎么才能把我的:
- XML code
<filter> <member><![CDATA[[Customer].[Country].&[#temp]]]></member> </filter>
------解决方案--------------------
- Java code
package csdn.xml; import org.dom4j.Document; import org.dom4j.DocumentException; import org.dom4j.DocumentHelper; import org.dom4j.Element; public class Test { public static void main(String[] args) throws DocumentException { String xml = "<?xml version='1.0' encoding='utf-8'?>" + "<filter>" + "<member><![CDATA[[Customer].[Country].&[#temp]]]></member></filter>"; Document doc = DocumentHelper.parseText(xml); Element rootEle = doc.getRootElement(); String member = rootEle.selectSingleNode("/filter/member").getText(); member = member.replaceAll("#temp", "Canada"); System.out.println(member); } }