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]
> &lt;Student-Names&gt;
>     &lt;name&gt;ABC&lt;/name&gt;
>     &lt;name&gt;BBC&lt;/name&gt;
>     &lt;name&gt;CBC&lt;/name&gt;
>     &lt;name&gt;ACB&lt;/name&gt;
> &lt;/Student-Names&gt;
> [/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]
> 
> &lt;Student-Names&gt;
>     &lt;name&gt;ABC&lt;/name&gt;
>     &lt;name&gt;BBC&lt;/name&gt;
>     &lt;name&gt;CBC&lt;/name&gt;
>     &lt;name&gt;ACB&lt;/name&gt;
> &lt;/Student-Names&gt;
> 
> &lt;Teacher-Names&gt;
>     &lt;name&gt;ABC&lt;/name&gt;
>     &lt;name&gt;BBC&lt;/name&gt;
>     &lt;name&gt;CBC&lt;/name&gt;
>     &lt;name&gt;ACB&lt;/name&gt;
> &lt;/Teacher-Names&gt;
> .....
> 
> [/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]

Reply via email to