Delphi 的例子请看:http://www.delphibbs.com/delphibbs/dispq.asp?lid=495235
节选:
uses comobj;
...
var xmlobj, node: Variant;
begin
xmlobj := CreateOLEObject('MSXML2.DOMDocument');
xmlobj.async := false;
xmlobj.load('http://www.delphibbs.com/delphibbs/chkl.asp?recnum=0');
node := xmlobj.selectSingleNode('LIST/HEADER/RecCount');
if not VarIsEmpty(node) then
ShowMessage('大富翁论坛今天更新的贴子数:' + node.Text);
xmlobj.Save('c:/updates_today.xml');
xmlobj := unAssigned;
end;
Java 的例子请看:http://www.delphibbs.com/delphibbs/dispq.asp?lid=539768
节选:
import java.net.*;
import javax.xml.parsers.*;
import org.w3c.dom.*;
import org.apache.xpath.*;
public class testChkl {
public static void main(String[] args) {
try {
URL url = new URL("http://www.delphibbs.com/delphibbs/chkl.asp?recnum=0");
do
cumentBuilderFactory dfactory =do
cumentBuilderFactory.newInstance();
do
cumentdo
c = dfactory.newDocumentBuilder().parse(url.openStream());
String xpath = "/DFWML/HEADER/RecCount";
Node n = XPathAPI.selectSingleNode(doc, xpath);
if (n != null) {
System.out.println("大富翁论坛今天更新的贴子数:" + n.getFirstChild().getNodeValue());
}
}
catch(Exception e) {
System.err.println(e.toString());
}
}
}