I need to access the virtual-host element, but开发者_开发问答 I don't know how to access the contents of this file programatically.
Fire up your favourite programming language that understands XML and parse the server.xml file. Use XPath to locate the element you're interested in and change it. Then write the server.xml file back out again.
If you're into Java and DOM then something like this would get you started:
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document document = documentBuilder.parse(new InputSource(new FileReader("/path/to/your/server.xml")));
// And start exploring the NodeList...
NodeList nodeList = document.getFirstChild().getChildNodes();
精彩评论