[jdom-interest] help please
Ian Lea
ian.lea at blackwell.co.uk
Tue Mar 27 01:58:54 PST 2001
The one line of code you show looks fine and works for me:
$ cat x.java
import org.jdom.Document;
import org.jdom.input.SAXBuilder;
import java.io.FileInputStream;
public class x {
public static void main(String[] args) throws Exception {
Document doc = new SAXBuilder().build(new FileInputStream(args[0]));
System.out.println(doc.getRootElement().getChild("EightToNine").getChild("Description").getText());
}
}
$ cat x.xml
<?xml version="1.0" encoding="UTF-8"?>
<diary>
<EightToNine>
<Description>This is a description.</Description>
<Note>This is a note</Note>
</EightToNine>
</diary>
$ java x x.xml
This is a description.
Compiled and run with jdom-b6 and xerces_1.2.3 and current directory
in the classpath.
--
Ian.
ian.lea at blackwell.co.uk
Hugh Mc Gauran wrote:
>
> I have posted a couple of times before and the answers have been very
> helpful, i hope someone can help me with thois problem
>
> I have an xml document 21-3-01.xml
>
> i want to be able to read it in and get the text contained in the
> description and the note ...no matter what i do it just wont work for
> me. any ideas
>
> i have tried
> doc.getRootElement().getChild("EightToNine").getChild("Description").getText();
>
> to no avail...
> the xml file is as follows
>
> <?xml version="1.0" encoding="UTF-8"?>
> <diary>
> <EightToNine>
> <Description>This is a description.</Description>
> <Note>This is a note</Note>
> </EightToNine>
> </diary>
>
> --
> Regards
> Hugh
More information about the jdom-interest
mailing list