Display TAGs with JSP

Hello there,

I’m verry new at JSP and Java. Installed Tomcat and the Telephone example from Tamino.
All this works fine. What I really would like to display is only the XML starttags and not the content. F.ex. a pulldownlist with available XML tags.
Someone who can help? We need to know whats possible so we can decide wich programming language we will use for accessing Tamino.
Thanks in advance!

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<%@ page language=“java” contentType=“text/html” %>
<%@ page import=“com.softwareag.tamino.API.dom.*” %>
<%@ page import=“org.w3c.dom.Element” %>


A simple Tamino access example with jsp


<%
TaminoClient myTC = new TaminoClient(“http://localhost/tamino/test/Telephone”);
myTC.setPageSize(5);
TaminoResult myTR = myTC.query( “Telephone[@ino:id=1]” );
while (myTR.hasMoreElements()) {
Element myElement = myTR.getNextElement();
%>
<%=myElement.toString()%>
<% } %>
Done!


:confused:

Do you mean get the Tagname instead of a string representation of the the element?

not <%=myElement.toString()%>
but
<%=myElement.getNodeName()%>

Almost! What I need is the starttag of each XML element within the resultset.

Below the result in HTML. As you can see it displays the first NODE and the NodeName as you told me.

What I want is a list with this:

Telephone
LoginName
PassWord
Lastname
Firstname

OK?

Result:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>


A simple Tamino access example with jsp



Wehlmann125Wehlmann124WehlmannAnton<Date_of_Birth>02.01.1945</Date_of_Birth><Company_Name>Deutsche Bank</Company_Name>HerrWehlmann124@web.deSeitersweg 200Darmstadt64287Germany06150-4140406150-896177

Telephone

Done!

Hi there,

TaminoResult myTR = myTC.query(“Telephone [LoginName~="W*"]”);
/* cast for enumeration /
Enumeration e = myTR;

if ( !e.hasMoreElements() )
out.println("Query :Telephone[LoginName~="W
"] No elements found !" );
else
while( e.hasMoreElements() ){
Element el=(Element)e.nextElement();
for ( int x = 0; x < 10; x++ ) {
String name = el.getElementsByTagName(“*”).item(x).getNodeName();
out.println(name);
}
}

The For loop
for ( int x = 0; x < 10; x++ ) {

contains x<10 so it will only do the first 10 elements.

I want to print out all the elements. I guess there’s a .count method. I’ll try to find it but if anyone could give a tip I will be verry pleased.

Regards,
Francis

getElementsByTagName() returns a NodeList object, and the NodeList has a getLength() method to tell you how many Nodes it contains.

So if you use two steps:

Element el=(Element)e.nextElement();
NodeList myList = el.getElementsByTagName(*);
for ( int x = 0; x < myList.getLength(); x++ ) {
String name = myList.item(x).getNodeName();
out.println(name);
}
}
it should work.

[This message was edited by Bill Leeney on 07 Dec 2001 at 15:07.]

It works, thanks.
By the way: ther’re quotes needed:
NodeList myList = el.getElementsByTagName();
should be
NodeList myList = el.getElementsByTagName("
");

Francis