I wanted to use an XML
parser with an SGML
document, however this doesnt work. After reading some suggestions it seems to only way around this is to use a HTML
parser. So im basically just trying to do a simple query that will extract the story title from my document. (It works if I parse null - prints the whole document, just im not sure how to access a specific tag e.g. title).
public static void main(String[] args){
Parser parser = new Parser(xmlFile.getAbsolutePath());
NodeList list = parser.parse (new HasAttributeFilter ("id","title"));
Node node = list.elementAt(0);
if (node instanceof TagNode) {
TagNode meta = (TagNode) node;
String description = meta.getAttribute("title");
System.out.println(description);
}
}
Start of SGML file:
<head>
<meta words=61 rate=180>
<formname>Testing</formname>
<storyid>1234</storyid>
</head>
<story>
<fields>
<f id=title>Sports</f>
<f id=modify-by>Tester</f>
<f id=modify-date>315576000</f>
</fields>
<body>