Tanks for yours advices. Finally I've solved using the "DocumentBuilderFactory" method.
//Take the xml file and change attribute tag: DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); Document doc = docBuilder.parse("C:\\layer.xml); NodeList nodes = doc.getElementsByTagName("Filter"); Node filter = nodes.item(0); filter.setTextContent("PROPERTY>5"); Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //initialize StreamResult with File object to save to file StreamResult result = new StreamResult(new StringWriter()); DOMSource source = new DOMSource(doc); transformer.transform(source, result); String xmlString = result.getWriter().toString(); //Riporta a stringa il contenuto dell'XML //System.out.println(xmlString); //out.println("<br>"+xmlString+"<br>"); //Write the modification to xml file: OutputStream f0; byte buf[] = xmlString.getBytes(); f0 = new FileOutputStream("C:\\layer2.xml"); for(int i=0;i<buf.length;i++) { f0.write(buf[i]); } f0.close(); buf = null; //Save the updated layer definition to the session repository using the ResourceService object. String filexml = "C:\\layer2.xml"; MgByteSource byteSource = new MgByteSource(filexml); byteSource.SetMimeType(MgMimeType.Xml); MgResourceIdentifier tempLayerResId = new MgResourceIdentifier("Session:" + sessionId + "//templayer.LayerDefinition"); MgByteReader header_byteReader = null; resourceService.SetResource(tempLayerResId, byteSource.GetReader(), header_byteReader); -- View this message in context: http://osgeo-org.1803224.n2.nabble.com/Help-regarding-to-set-filter-for-a-layer-programmatically-using-Java-tp3343625p5976493.html Sent from the MapGuide Users mailing list archive at Nabble.com. _______________________________________________ mapguide-users mailing list mapguide-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapguide-users