A
Andi
Hi,
I have following xml files:
tools.xml:
<?xml version="1.0" encoding="utf-8"?>
<Tools xmlns:xi="http://www.w3.org/2001/XInclude">
<Tool name="tool1" id="1">
<xi:include href="instruments.xml" xpointer="element(/1/1)"/>
</Tool>
</Tools>
instruments.xml:
<?xml version="1.0" encoding="utf-8"?>
<Instruments>
<Instrument id="Temperature" type="Temperature" name=""/>
<Instrument id="Humidity" type="Humidity" name=""/>
<Instrument id="Massflow" type="Massflow" name=""/>
</Instruments>
I am using the following code to parse the xml:
public void testApp()
{
try
{
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setXIncludeAware(true);
factory.setNamespaceAware(false);
factory.setValidating(false);
SAXParser parser = factory.newSAXParser();
SAXReader reader = new SAXReader(parser.getXMLReader());
Document doc = reader.read(new File
(AppTest.class.getResource("/tools.xml").toURI()));
XMLWriter writer = new XMLWriter(System.out);
writer.write(doc);
}
catch (Exception e)
{
e.printStackTrace();
}
}
With
<xi:include href="instruments.xml" xpointer="element(/1/1)"/>
it works. Now I want to get the element with the id "Temperature".
Don't know how to do this.
Using jdk-1.6_10 and dom4j-1.6.1
Thanks for every hint
I have following xml files:
tools.xml:
<?xml version="1.0" encoding="utf-8"?>
<Tools xmlns:xi="http://www.w3.org/2001/XInclude">
<Tool name="tool1" id="1">
<xi:include href="instruments.xml" xpointer="element(/1/1)"/>
</Tool>
</Tools>
instruments.xml:
<?xml version="1.0" encoding="utf-8"?>
<Instruments>
<Instrument id="Temperature" type="Temperature" name=""/>
<Instrument id="Humidity" type="Humidity" name=""/>
<Instrument id="Massflow" type="Massflow" name=""/>
</Instruments>
I am using the following code to parse the xml:
public void testApp()
{
try
{
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setXIncludeAware(true);
factory.setNamespaceAware(false);
factory.setValidating(false);
SAXParser parser = factory.newSAXParser();
SAXReader reader = new SAXReader(parser.getXMLReader());
Document doc = reader.read(new File
(AppTest.class.getResource("/tools.xml").toURI()));
XMLWriter writer = new XMLWriter(System.out);
writer.write(doc);
}
catch (Exception e)
{
e.printStackTrace();
}
}
With
<xi:include href="instruments.xml" xpointer="element(/1/1)"/>
it works. Now I want to get the element with the id "Temperature".
Don't know how to do this.
Using jdk-1.6_10 and dom4j-1.6.1
Thanks for every hint