Yes, you can use XPath API to return NodeList instead of evaluating to a
text value.
http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/xpath/XPath.html#evaluate(java.lang.String,%20java.lang.Object,%20javax.xml.namespace.QName)
-Prashant
legolas wood wrote:
Thank you for reply.
I looked at Xpath API, but it just return an string as the result of
evaluation.
while I need it to return a NodeList or something similar to it.
imagine that i want to pars something like :
<Student-Names>
<name>ABC</name>
<name>BBC</name>
<name>CBC</name>
<name>ACB</name>
</Student-Names>
<Teacher-Names>
<name>ABC</name>
<name>BBC</name>
<name>CBC</name>
<name>ACB</name>
</Teacher-Names>
.....
If i apply the Xpath API, will it return a NodeList of all element
inside
<Teacher-Names>
thanks
Michael Glavassevich wrote:
legolas wood <[EMAIL PROTECTED]> wrote on 12/20/2006 09:37:54 AM:
Thank you for reading my post.
I have some question about parsing XML,
-does XSD and DTD has the same role?
They're different schema languages. Wikipedia [1] has a fairly good
comparison of the two.
-I know that if i want to pars a document like :
[CODE]
<Student-Names>
<name>ABC</name>
<name>BBC</name>
<name>CBC</name>
<name>ACB</name>
</Student-Names>
[/CODE]
I should have a code like:
[CODE]
Element docEle = dom.getDocumentElement();
NodeList nl = docEle.getElementsByTagName("name");
[/CODE]
But when my XML document is more sophisticated like :
[CODE]
<Student-Names>
<name>ABC</name>
<name>BBC</name>
<name>CBC</name>
<name>ACB</name>
</Student-Names>
<Teacher-Names>
<name>ABC</name>
<name>BBC</name>
<name>CBC</name>
<name>ACB</name>
</Teacher-Names>
.....
[/CODE]
what should i do?
Should i start reading the document elements one by one and test them to
see whether it is student/teacher/worker.... or there is some easier way
like case one that i can use to retrieve all
students/teachers/workers..?
You may find it easier to select the content you want using XPath (which
is supported [2] by Xalan).
Thanks.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
[1] http://en.wikipedia.org/wiki/XML_Schema_Language_Comparison
[2] http://xml.apache.org/xalan-j/xpath_apis.html
Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: [EMAIL PROTECTED]
E-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]