Hello,

i can't get running the xpath selector to get the node "Dataname"... can anyone 
help me please?
The xml file has a xsd reference... without it.. i have no problems.. but i 
need it for the validation...


THANK YOU !!!


SAXReader reader = new SAXReader();
reader.setValidation(false);
org.dom4j.Document document = reader.read(new File("D:/TMP/test.xml"));

String expression = "//File[starts-with(Dataformat,'Word')]/Dataname";
XPath xpath = document.createXPath(expression);
Node n = xpath.selectSingleNode( document );
log.debug("!" + n.getText());

~~~~~~~~ test.xml ~~~~~~~~~~~~~~~~~
<?xml version="1.0" encoding="UTF-8"?>
<XFile xmlns="http://www.example.de"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://www.example.de example_root_1_0.xsd" Version="1.0">
        <XFile_Data>
                <Dokument>
                        <Ident>
                                <ID>TF9B60A0-1431-4F62-BC68-3311714A69AD</ID>
                        </Ident>
                        <File>
                                <Dataname>mydokument.doc</Dataname>
                                <Dataformat wd_version="1.0" 
wd_fassung="0">Word 10.0</Dataformat>
                                <Date>2005-08-13</Date>
                        </File>
                </Dokument>
        </XFile_Data>
</XFile>
~~~~~~~~~~~~~~~~~~~~~~~~~
-- 
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! 
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
dom4j-user mailing list
dom4j-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to