How to retrieve child attribute names in XML?

How do I retieve only the child attribute names from the XML.
XML:
<catalog>
     <book>
           <author></author>
           <title></title>
           <genre></genre>     
           <price></price>    
     </book>
</catalog>Expecting result:
author
title
genre
price
I tried with the SAX Parser and class extending DefaultHandler it returns catalog and book aswell which I do not want to retrieve.
public void startElement(String namespaceURI, String localName,
                                 String qName, Attributes atts)  {
               System.out.println(qName)
//this returns catalog and book along with the other attribute names
}

gsry wrote:
jverd wrote:
Your problem is not clear. Are you saying you want only the leaf nodes? Or are you saying you want all the /catalog/book child nodes, even if they're not leaf nodes? Or something else?I do not know what leafy nodes mean but i want to retrieve all the child nodes (tag names).
<catalog>
     <book1>
           <author1></author1>
           <title1></title1>
     </book1>
     <book2>
           <author2></author2>
           <title2></title2>
     </book2>
</catalog>In this example i want to retrieve author1, title1, author2, title2
Also, you're still not specific enough. For instance, what if there's another layer before author and title. Do you want that? What about if there's another level under author and title, do you want that? Can those situations even happen?
Do you want nodes at a certain level?
At a certain level and below?
Always author and title nodes, regardless of where they appear?
Always author and title, but only if they're immediately enclosed by book? Or by book<some number>?
Author and title only when they're under /catalog/book?
If you can't specify your requirements precisely, it's going to be awfully hard for someone to help you.

Similar Messages

  • How to retrieve the parameter names from a JSP page ? Urgent Please

    Hello,
    Can anybody tell me how to retrieve the parameter names from the JSP
    page. (without using getParameterNames() method.)
    The problem with the getParameterNames() method is I get the Jumbled output.
    I need it very badly
    With regards
    Ananth R
    email:[email protected]
    [email protected]

    Dear duffymo,
    My primary intention is to convert the JSP form information into a XML file.
    If I do not get the Parameter names in the correct order how can I maintain
    tag order in XML file.
    For ex: (JSP PAGE VIEW)
    Name--
    FirstName
    MiddleName
    LastName
    Address--
    Street1
    Street2
    City
    Country
    &so on
    (XML File to be generated)
    <Name>
    <FirstName>Value</FirstName>
    </Name>
    <Address>
    <street1>value</street1>
    </Address>
    & so on
    If I use getParameterNames() to get all the parameter names(Which form the tag names in the XML file ) the Enumeration object it returns will not be in the same order as the text fields in JSP.From this I can not construct a meaningful XML file.
    order means: Order of entry on the page, from top to bottom
    That's it
    Waiting for your responses

  • How to retrieve elements from 3 different xml file in one url

    Hi all,
    Could anyone please let me how can we retrieve elements from 3 different xml file in one url?
    i just can only do it with one file only, any help would very appreciate.
    Thank in advance
    Jim

    Hi Philip
    Thanks for replying me.
    I tried on that way, In my mdx query i am using one slice attribute (i.e [Customer].[Gender].allmembers) in rows so getting error "The  Hierarchy already appears in Axis1".
    SELECT
    {[Measures].[Internet Sales Amount] } ON 0,
    NON EMPTY
    {[Customer].[Gender].allmembers } ON 1 -- Used
    FROM
    [Adventure Works]
    WHERE
    [Customer].[Gender].&[M]
    ,[Product].[Size Range].[(All)]
    ,[Customer].[Country].[All Customers]
    [Customer].[Gender].[All Customers]
    ,[Product].[Size Range].&[XL]
    ,[Customer].[Country].[All Customers]
    [Customer].[Gender].[All Customers]
    ,[Product].[Size Range].[(All)]
    ,[Customer].[Country].&[Australia]
    Can you provide alternate ways to get resolved.
    Thanks in advance

  • How to read an attribute of an xml tag in jsp.

    hi guys,
    This is murali krishna. i have a small problem,
    i have one xml file (books.xml)
    <?xml version="1.0" encoding="iso-8859-1"?>
    <library>
    <book id="1">
    <name>Head First Java, 2nd Edition</name>
    <author>Kathy Sierra and Bert Bates</author>
    <publication-date>09-Feb-2005</publication-date>
    </book>
    <book id="2">
    <name>Effective Java</name>
    <author>Joshua Bloch</author>
    <publication-date>28-May-2008</publication-date>
    </book>
    <book id="3">
    <name>Java How to Program, 7th Edition</name>
    <author>Harvey M. Deitel and Paul J. Deitel</author>
    <publication-date>6-Jan-2007</publication-date>
    </book>
    </library>
    I tried to read this xml file in jsp as shown below
    <%@ page language="java" %>
    <%@ page import="org.w3c.dom.*" %>
    <%@ page import="javax.xml.parsers.DocumentBuilder" %>
    <%@ page import="javax.xml.parsers.DocumentBuilderFactory" %>
    <%
    DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance();
    DocumentBuilder db =dbf.newDocumentBuilder();
    Document doc=db.parse("c:\\books.xml");
    NodeList nl = doc.getElementsByTagName("book");
    %>
    <html>
    <head>
    <title>How to read XML file in JAVA</title>
    </head>
    <body>
    <%
    for(int i=0;i<nl.getLength();i++)
    NodeList nameNlc= doc.getElementsByTagName("name");
    Element nameElements=(Element)nameNlc.item(i);
    String nameTagValue=nameElements.getChildNodes().item(0).getNodeValue();
    NodeList authorNlc= doc.getElementsByTagName("author");
    Element authorElements=(Element)authorNlc.item(i);
    String authorTagValue=authorElements.getChildNodes().item(0).getNodeValue();
    NodeList dateNlc= doc.getElementsByTagName("publication-date");
    Element dateElements=(Element)dateNlc.item(i);
    String dateTagValue=dateElements.getChildNodes().item(0).getNodeValue();
    out.println("name :"+nameTagValue+"<br>");
    out.println("author :"+authorTagValue+"<br>");
    out.println("publication-date :"+dateTagValue+"<br><br>");
    %>
    </body>
    </html>
    so, my problem is I was unable to read the attribute of the tag book , that is "id".
    can any one tell me how to read this "id" attribute.
    Murali Krishna
    [email protected]

    hi,
    U r retriving the elements by tag name.So it just chks the tag name ie.<book> & gives u array of elements.But u need retrive d attribute of <book> tag itself.
    =Solution =====
    Add one more statement ----> var[]= doc.getElementsByName("book");
    Now u hav book elements as an array & can retrive id in for loop
    for(var; var.length;var++)
    doc.element[var].id.value

  • How to find database attribute names that correspond to page labels

    I've been tasked with creating one or more views to be used in creating reports. The users know data items by the labels on pages, not the database attribute names. So my dilemma is how to correlate the page labels to the database attributes.
    For example, there's a course details web page. It includes items labeled "Replacement Course", "Inherited Competency Update Setting" and "Attachments", among others.
    Focusing on "Inherited Competency Update Setting"... there's no database attribute called that. I've found COMPETENCY_UPDATE_LEVEL, but I don't know if that is it. And is an "inherited" one different than a non-inherited.
    I've googled about, and discovered that "Inherited Competency Update Setting" can be set by using a workflow named OTA_COMPETENCE_UPDATE_JSP_PRC and setting an attribute named HR_APPROVAL_REQ_FLAG. Further research has lead me to determine that HR_APPROVAL_REQ_FLAG is used only within the workflow system. I've found in SYS.ALL_SOURCE a package OTA_COMPETENCE_SS with a function that gets that attribute's value. It includes a query against WF_ACTIVITY_ATTR_VALUES which retrieves values of YES_DYNAMIC, APPROVAL, NO, YES or NOTIFYONLY. I've not found any code that uses the function.
    Using ALL_TAB_COLUMNS, I'd found COMPETENCY_UPDATE_LEVEL in OTA_OFFERINGS, which contains "APPROVAL" or null. So that may be what I seek, but I can't confirm it.
    I also have been unable to find the translation from "APPROVAL" to "Notification, Automatic Update after Approval" (assuming I'm correct and this is the field)
    I've found a Training Administration Technical Reference Manual for Release 11i, which contains information about the database, but I've found no corresponding document for Learning Management for 12.1 (Only installation and user guides).
    And this is many days' research to find one attribute. Which I'm not certain I've found.
    So, in this case in particular, or any case in general, how does one find the database name for an attribute, given the page label's text??
    Thank you
    Cornell

    Whoa, easier than I'd thought...
    When the page first shows up, there's the About This Page link, at the bottom, clicking it you get to the About Page.
    I noted two sections, Page Definition and Business Component References Details.
    I expanded Business Component References Details and found View Objects. There's a list of views used. I was dismayed that the views don't appear to be in the database. Of course, they're camelCased Java names of Java objects, not database names (although sometimes some of the camelCased tokens might correspond to parts of view names). They are, however, clickable and when clicked the definition shows up, and I was thinking that it would take a long while to find what I was seeking.
    But... Hit the Expand All link in Page Definition, do a find on page for the desired label, and there it is... a row with the label, view object name and attribute! Pay dirt!
    Then go to the Business Component References Details, find the View Object, click it, and there's the view :-) Find the attribute, then the table... easy peasy!
    Thank y'all again

  • How to retrieve various file names from a filepath of application server

    Hi All,
    I am using a FILEPATH  of application server which can have multiple file names i want to retrieve data from all the existing files.
    i am using FM "GET_NAME_FILE" but it is applicable only for file name.
    so my question is how to fetch various file names of particular filepath.
    Thanks in advance.

    Hello Mayank,
    You can use the below FM and code
    PARAMETERS: p_file TYPE rlgrap-filename.
    ***AT Selection-Screen*******
    AT SELECTION-SCREEN ON  VALUE-REQUEST FOR p_file.
    ***Function  module for F4 help from Application  server
      CALL FUNCTION '/SAPDMC/LSM_F4_SERVER_FILE'
    * EXPORTING
    *   DIRECTORY              = ' '
    *   FILEMASK               = ' '
       IMPORTING
       serverfile             =  p_file
       EXCEPTIONS
       canceled_by_user       = 1
       OTHERS                 = 2
      IF sy-subrc = 0.
        MESSAGE 'Successful'  type 'I'.
      ENDIF.
    Regards,
    Mithun Shetty

  • How to change the attribute name for a relation

    When the Data Modeler engineers a logical model into a relational model it create table columns for the relations. The names of the generated columns are listed in the attributes list in the properties dialog of the relation. The actual name of the attribute gets calculated by the attribute name of the entity which is part of the relation. This is okay, if there is only one relation between two entities. But when there are two relations between two entities the second attribute gets a stupid number suffix. This makes it impossible to give the attribute a useful semantic meaning.
    When I engineer the model into a relational model I can change the column name in the relational model. Changing the column name in the relational model is not perfect but it would be okay for me, if it would not be overwritten during the next engineering run.
    So I have two questions:
    How can I change the attribute name in the attributes section of the properties dialog of a relation? See here for screen shot:
    http://public.ceving.de/2012050300/relationattribute.png
    And if it is not possible:
    How can I preserve any changes on column names in the relational model during a re-engineering run?
    Edited by: 931739 on 03.05.2012 08:07

    Hi,
    I've logged an Enhancement request on this.
    I don't believe it's possible to change it from the Entity or Relationship dialog, as it's not updatable in these dialogs.
    What you can do is change it in the Relational Model, and then reverse engineer the change back to the Logical Model.
    David

  • How to retrieve the Field Name of a Table

    Hi guys,
    I'm trying to retrieve the field name of a table in java, but i don't know how to do it. Could somebody help me?Let say i have a table name Itemmaster, then
    i want to retrieve its field and display to dos prompt.
    Example :
    Item No.
    Description
    Quantity
    It is possible to retrieve the fields?
    What could be the possible command in java using packages Java.sql.*?
    Thanks in advanced...
    Best regards,
    Dharry

    The ResultSet class, which is how query results are returned in JDBC, has methods to get at the metadata for the table queried, including column names:
    ResultSet resultSet=statement.executeQuery("select * from table");
    resultSetMetadata=resultSet.getMetaData();
    resultSetMetadata.getColumnLabel(column+1);

  • How to access XM attribute name in servlet ?

    Hi All,
    Anybody please tell me how to access attribute name in servlet ?
    Thanks

    Hi All,
    I have modified the source code of af:showDetailItem as following:
    <af:forEach items="#{bindings.VerticalAppMenus.children}" var="globalMenu" varStatus="globalMenuVarStatus">
               <af:showDetailItem text="#{globalMenu.MenuLabel}" id="sdi1" disclosureListener="#{pageFlowScope.globalMenus.refreshLineMenus}"
                 disclosed="#{(pageFlowScope.globalMenus.currentVerticalMenuId == globalMenu.MenuId) ? true : false}">
                  <f:attribute name="currentVerticalMenuId" value="#{globalMenu.MenuId}"/>
    </af:showDetailItem>
    </af:forEach>For the code *disclosed="#{(pageFlowScope.globalMenus.currentVerticalMenuId == globalMenu.MenuId) ? true : false}"*, at runtime it is giving the following error:
    *java.lang.IllegalArgumentException: Cannot convert 32 of type class oracle.jbo.domain.Number to class java.lang.Long*.
    Is there any way to cast the long to number or number to long in EL?
    Any help will be highly appreciated
    Thanks ... Best Regards
    Bilal
    Edited by: Bilal on 04-Apr-2012 19:32

  • Flex 3 - How to change an attribute name ?

    like this
    <item code="1" />
    to
    <item id="1" />
    thanks

    Hi Alex,
    You can use setName to change the attribute name:
    Here for example change all your id attributes with code:
    var xmlTest:XML=<r><item id="1"/></r>;
    for each (var node:XML in xmlTest.item.descendants("@id"))
    node.setName("code");
    trace(xmlTest);
    Thanks,
    Bhasker

  • How to Retrieving Mandatory Filed name from Tcode.

    Hi,
    I need to retrieve mandatory field names from tcode like (mm01)  using abap programming..
    How to find that field name is mandatory?
    Thanks and Regards,
    Meena

    Hi Meena,
    I guess you need to manually find it out and make z-table which can be used for further logic.
    Once you have table for required fields, you can even add/remove any field depending on your requirement.
    I also faced the same issue and we maintained it in ztable as follows.
    MANDT  
    FIELDNAME   
    STATUS
    For STATUS , create fixed domain values as "REQUIRED", "HIDDEN", "GRAYED OUT".
    I hope this will help you.
    Regards,
    Rahul Mahajan

  • How to retrieve Process Role Name

    Hi @ all,
    can anyone tell me how to retrieve the Name of the actual processing Role in a web dynpro callable object.
    Until now I just found out how to get the technical name in the execute() method. Unfortunately it's not the human readable name.
    e.g.
    String name  = executionContext.getProcessRoleInstance().getProcessRoleTechName();
    Thanks and Regards
    Robert

    Hi Robert,
    After you created a process, block, action, and your WD GP interface callable object and would retrieve this information in custom way you can use the following coding:
    <code>
    String processId = executionContext.getProcessId() ;
    IGPRuntimeManager runtimeManager = GPProcessFactory.getRuntimeManager() ;
    IGPProcessInstance process = runtimeManager.getProcessInstance(processId, getCurrentUser()) ;
    IGPProcess processTemplate = (IGPProcess)process.getTemplate() ;
    int gpRolesSize = processTemplate.getRoleInfoCount() ;
    String roleDisplayName = null ;
    for (int i = 0; i < gpRolesSize; i++)
           IGPRoleInfo role = processTemplate.getRoleInfo(i) ;     if (role.getRoleName().equals(roleTechName))
                roleDisplayName = role.getText()
                break ;
    </code>
    Best regards,
    Aliaskei

  • How to change View Attribute Name?

    Is there a way to change the attribute name of a view object that was added from and entity Object?
    I dont want to change the Entity Attribute Name since i want to use it in diferent view objects with diferent names...

    Hi Frank
    It would be very convenient to have view object attribute name updateable because the attributes may result from different joins (to same table) and have different meaning depending more on the association than to the table attribute itself (in most case the relationship extend the meaning of the attribute).
    In my use case i have :
    A table FlexTypologyClassMatrix with two foreign key pointed to FlexTypologyClass primary table. That mean that my matrix have two axis defined by the primary key of FlexTypologyClass table.
    I created a view object that correspond to this scheme with eo's FlexTypologyClassMatrix, FlexTypologyClass as FlexTypologyClassAxisX, FlexTypologyClassAxisY).
    The view object attributes from eo's FlexTypologyClassMatrixAxisX or Y are generated from the table attribute name with a suffix like FlextypologyclassL (for FlexTypologyClassMatrixAxisX) and FlextypologyclassL1 (FlexTypologyClassMatrixAxisY).
    The attribute name are the most used item used later in the development cycle and this is not easy to distinguish the X from the Y without analyzing the view object definition. It's not a very productive way to develop application.
    It would be very convenient to permit the view object attribute name to be updateable or the alias name of the entity object in the view object has to be displayed with, every time.
    I didn't check if the info is displayed every tiem, may be it is a workaround !?
    Hope you understand what I mean. Thank you.

  • How to change the attributes of an XML file

    hi peeps 'ope you can help me here i need to change the attributes of an xml file, i parse it first using a DOM parser but i cant find a way to change the attributes in the XML file, setAttribute() works only at runtime and doesn't change the attribute in the file itself. I can't find a method that will answer my question. I've searched through the forum and found similar threads....they say in order to write and change the attribute i must use the write() method of the XmlDocument class defined in com.sun.xml.tree.XmlDocument. But, i found another thread, and it says that com.sun.xml.tree.XmlDocument is not safe to use and i should use org.apache.crimson.tree.XmlDocument.....i can't find the XmlDocument class and the API for this package so i really dont know where to start...hope you guys can help me! thnx

    thanks for responding roland....i already found the solution...i didn't use the XmlDocument class because i can't find any documents about it except for JAXP 1.0 here is my code snippet...i used the TransformerFactory and Transformer class to write
    import org.w3c.dom.*;
    import org.w3c.dom.traversal.*;
    import javax.xml.parsers.*;
    import javax.xml.transform.*;
    import javax.xml.transform.dom.*;
    import javax.xml.transform.stream.*;
    Document doc = null;
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    DocumentBuilder db = dbf.newDocumentBuilder();
    dbf.setValidating(false);
    doc = db.parse(fileGetFile); //this is the XML file
    n1 = (Node)doc.getDocumentElement();
    e1 = (Element) n1;
    NodeList nodeList = doc.getElementsByTagName ("File");
    //just insert whatever you want to do with the XML...parse it..set/change the attribute..etc....sample snippet below changes the attribute downloaded to "no"
    for(int iWriteFailed = 0; iWriteFailed <nodeList.getLength() ; iWriteFailed ++){     
    n2 = nodeList.item(iWriteFailed);
    e2 = (Element) n2;          
    e2.setAttribute("downloaded", "no");}
    try{
    TransformerFactory transformerFactory = TransformerFactory.newInstance();
    Transformer transformer = transformerFactory.newTransformer();
    transformer.transform(new DOMSource(doc), new StreamResult ( new FileOutputStream ( fileGetFile) ) );}
    catch(Exception trans){}
    thanks for responding and keeping the information interchange alive here in the forum...
    Pau

  • Struts: How to set 'disabled' attribute name using a property in ActionForm

    I have the following struts tag:
    <nested:select property="someProperty" disabled="<nested:write property="screenReadOnly"/>">
       <html:options .../>
    </nested:select>
    where 'screenReadOnly' is a boolean variable in the ActionForm.
    However this does not work. Is there a way to use this technique in a struts way (without using any scriplets) for attribute names instead of having duplicate struts tags where the only difference is, in this case, the disabled value?
    For those that are interested, I get the following thrown exception:
    weblogic.servlet.jsp.JspException: (line 120): Non-matching extension tags //[ null;
    Line: 120]
    at weblogic.servlet.jsp.JspLexer.jspException(JspLexer.java:856)
    at weblogic.servlet.jsp.JspLexer.mCLOSE_EXTENSION_TAG(JspLexer.java:2674)
    at weblogic.servlet.jsp.JspLexer.mTOKEN(JspLexer.java:1987)
    at weblogic.servlet.jsp.JspLexer.nextToken(JspLexer.java:1860)
    at weblogic.servlet.jsp.JspLexer.parse(JspLexer.java:1100)
    at weblogic.servlet.jsp.JspParser.doit(JspParser.java:89)
    at weblogic.servlet.jsp.JspParser.parse(JspParser.java:192)
    at weblogic.servlet.jsp.Jsp2Java.outputs(Jsp2Java.java:119)
    at weblogic.utils.compiler.CodeGenerator.generate(CodeGenerator.java:255)
    Cheers.
    Normie.

    Rule of thumb: You can't use tags for attribute values.

Maybe you are looking for

  • What is happening to my Mac.only blue screen appears

    After I download the latest firmware and itune I'm getting this blue screen when i open my computer.anyone have the same problem?

  • Something That May Be Interesting About The Yellow Screen Issue

    I was comparing my 3G and 3GS and have also been experimenting with looking at the color of the 3GS in different lighting environments. There was one situation where it appeared to be a little yellowish or warmer than the 3G, but mainly it is just no

  • Dreamweaver CS4 update links not working??

    Hello, I have recently installed DW CS4 for our web designer. I have the update links preference set to prompt. When I moved pdf file to another folder it never asked me to update links. It only said am I sure I wanted to move the file. Should this w

  • "Exception in "AWT-EventQueue-0""

    friends, i am getting an error when i want to handle an event(i.e. a button pressed). the error it throws is as follows Exception in "AWT-EventQueue-0" java.lang.NullPointerException at MyClass.actionPerformed(MyClass.java:12) actually i want to plac

  • Viewing videos from TV program

    Sometimes I miss a TV show. The TV network allows you to view videos of the show after the program has aired. When I try to see the video, it plays about 1 second, then stops while loading, plays another second, stops to load, etc. Is there any way t