How to get Value of TagName ?

Hi all,

i’m new to Tamino and need your help.

my XML structure look like this…

-
value
-
value01
value02

-
value03
value04


TaminoClient tc= new TaminoClient(collection);
tc.setPageSize(5);
tc.startSession();

try {String qr= “/parent[nr="”+nr+“"]/*”;
TaminoResult tr= tc.query( qr);
Enumeration enum = tr;
while (enum.hasMoreElements())
{
Element myElement = (Element)enum.nextElement();

Question: how can i get the value of the Tag

thnx you all

minskat

code:

NodeList myParentList = myElement.getElementsByTagName("parent01");
if (myParentList.getLength() > 0) {
Node myParent = myParentList.item(0);
System.out.println("My Parent: " + myParent.getFirstChild().getNodeValue());
}

Alternatively, because parent01 is usually the first element in your subtree, you could use:

code:

Node myParent = myElement.getFirstChild();
if (myParent.getNodeName().equals("parent01")) {
System.out.println("My Parent: " + myParent.getFirstChild().getNodeValue());
}


Both of these examples assume that parent01 has a text value if it exists at all. You may need to check for an empty node too.

To get an Attribute value you can use:

code:

String inoid = myElement.getAttribute("ino:id");

By the way, a TaminoResult object already implements java.util.Enumeration so you can invoke hasMoreElements() and nextElement() directly on the TaminoResult object. But if you execute getNextElement()instead, you get back an Element (you don't have to cast it from Object).

[This message was edited by Bill Leeney on 29 Nov 2001 at 09:34.]

[This message was edited by Bill Leeney on 29 Nov 2001 at 09:49.]

Thank you very much Bill.