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]