IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.


#TechXchangePresenter
 View Only
Expand all | Collapse all

How to get Value of TagName ?

  • 1.  How to get Value of TagName ?

    Posted Wed November 28, 2001 06:39 PM

    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


    #webMethods-Tamino-XML-Server-APIs
    #API-Management
    #webMethods


  • 2.  RE: How to get Value of TagName ?

    Posted Thu November 29, 2001 09:56 AM
    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.]


    #API-Management
    #webMethods-Tamino-XML-Server-APIs
    #webMethods


  • 3.  RE: How to get Value of TagName ?

    Posted Fri November 30, 2001 09:36 AM