I need to get the tagName of a node of the first child of the Root

Hi All,
I need to get the TagName of the Node immediete after the Root. I won't know what is the TagName, and based on the Tagname only I can process the records.
For example I might receive a SALES object or a MARKETING object wrapped under the root.
eg.
<PARENT>
<SALES>
</SALES>
</PARENT>
or
<PARENT>
<MARKETING>
</MARKETING>
</PARENT>
I tried to using like this
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
File file = new File("c:/example.xml");
document = documentBuilder.parse(file);
Node node = document.getDocumentElement().getFirstChild();
System.out.println("node Name:" +node.getNodeName());
System.out.println("node Value:" +node.getNodeValue());
It returns only something like #text, but I need the response like 'SALES'.
Can anyone let me know if im missing something somewhere.
thanks in advance,
Harish

Hi Blaise,
thanks for your reply.
but still i couldn't get the tag name even after using setIgnoringElementContentWhitespace true.
          Document document = null;
          DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
          documentBuilderFactory.setIgnoringElementContentWhitespace(true);
          try
               DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
               File file = new File("c:/example.xml");
               document = documentBuilder.parse(file);
               Node node = document.getDocumentElement().getFirstChild();
               System.out.println("node.getNodeName: "+node.getNodeName());
               System.out.println("node.getNodeValue: "+node.getNodeValue());
it really confuses what im going wrong.
can you let me know if the code that i have given is correct?
thanks,
Harish

Similar Messages

  • I need to get the tagName after a node of the first child of the Root

    Hi All,
    I need to get the TagName of the Node immediete after the Root. I won't know what is the TagName, and based on the Tagname only I can process the records.
    For example I might receive a SALES object or a MARKETING object wrapped under the root.
    eg.
    <PARENT>
    <SALES>
    </SALES>
    </PARENT>
    or
    <PARENT>
    <MARKETING>
    </MARKETING>
    </PARENT>
    I tried to using like this
                   DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
                   File file = new File("c:/example.xml");
                   document = documentBuilder.parse(file);
                   Node node = document.getDocumentElement().getFirstChild();
                   System.out.println("node Name:" +node.getNodeName());
                   System.out.println("node Value:" +node.getNodeValue());
    It returns only something like #text, but I need the response like 'SALES'.
    Can anyone let me know if im missing something somewhere.
    thanks in advance,
    Harish

    That's because the first child of the document element is that whitespace text node between <PARENT> and <SALES>. You need to scan through the children of the document element until you find one that is an Element node.

  • !!! I need to get the return value from a PL/SQL in Java.. How??? !!!

    Hi
    -- I have a PL/SQL in which it return an array value and I need to get the value using Java.... any idea how?
    thanks

    Check out CallableStatement:
    http://java.sun.com/j2se/1.5.0/docs/api/java/sql/CallableStatement.html

  • I saved photos from my Macbook Pro onto my Iphone (using itunes, 4 years ago). My macbook is now dead and I need to get the photos I saved off of my iphone 3GS transferred to a pc.  Any help...  From my PC I can only access "internal storage"

    I saved photos from my Macbook Pro onto my Iphone (using itunes, 4 years ago). My macbook is now dead and I need to get the photos I saved off of my iphone 3GS transferred to a pc.  Any help...  From my PC I can only access "internal storage"

    The iphone is not a storage/backup device.  The picture sycn is one way - computer to iphone.  The photos are also reduced in size when synced to iphone so they are not of the original quality
    It has always been very basic to always maintain a backup of your computer.
    Have you failed to do this?
    If so, not good at all, you can e-mail the pics to yourself - keep in mind they will never be of the original quality

  • I am trying to make a pdf of a file and I need to get the file size to be no bigger than 10MB. What is the best way to do this

    I am trying to make a pdf of a file and I need to get the file size to be no bigger than 10MB. Even when I save it, the image quality at minimum the file size is 10.9 MB. What is the best way to do this

    @Barbara – What purpose is that PDF for? Print? Web?
    If web purpose, you could convert CMYK images to sRGB. That would reduce the file size as well.
    A final resort to bring down file size is:
    1. Print to PostScript
    2. Distill to PDF
    That would bring file size down even more. About 20%, depending on the images and other contents you are using, compared with the Acrobat Pro method. If you like you could send me a personal message, so we could exchange mail addresses. I could test for you. Just provide the highres PDF without any downsampling and transparency intact. Best provide a PDF/X-4.
    I will place the PDF in InDesign, print to PostScript, distill to PDF.
    Uwe

  • My iPhone 5 is not catching up my website, although having a big screen... What does it need to get the pages in auto mobile queries converting?

    my iPhone 5 is not catching up my website, although having a big screen... What does it need to get the pages in auto mobile queries converting?

    You need to code your web site to recognize the mobile browser and send a page that's actually usable when it does.

  • Need to get the Mail attachment name as it is to the receiver file adapter

    I am doing a Mail to File scenario. I need to get the attachment from the mail and store it on the file server. I am using the PayloadSwap bean in the sender mail adapter. My requirement is to carry forward the attachement name as it is to the receiver file adapter side and store the file with the same name.
    Did any one try doing this? I was looking at developing an adapter module but got struck as I could not find whether the attachement name is stored in the XI payload after it has got swapped using the swap bean.
    Any help would be appreciated.
    VJ

    Oops pressed the send key. Take two.
    This is becoming a damn nightmare. When I run the adapter I am getting ModuleExceptions. Can you pass your eyes over these Java config settings to see what I am doing wrong. Using NWDS CE 7.1 with PI 7.1 both at SP07. All the imports were taken from PI 7.1 after SP07 was applied. The build id of NWDS is
    SAP NetWeaver Developer Studio
    SAP NetWeaver 7.1 Composition Environment SP07 PAT0001
    Build id: 200901152336
    APPLICATION.XML
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE application PUBLIC "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN"
    "http://java.sun.com/dtd/application_1_3.dtd">
    <application>
    <display-name>MailPOP_EAR</display-name>
    <description>EAR description</description>
    <module>
    <ejb>MailPOP_EJB.jar</ejb>
    </module>
    </application>
    APPLICATION-J2EE-ENGINE.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE application-j2ee-engine SYSTEM "application-j2ee-engine.dtd">
    <application-j2ee-engine>
    <reference reference-type="hard">
    <reference-target provider-name="sap.com" target-type="service">engine.security.facade</reference-target>
    </reference>
    <reference reference-type="hard">
    <reference-target provider-name="sap.com" target-type="library">engine.j2ee14.facade</reference-target>
    </reference>
    <reference reference-type="hard">
    <reference-target provider-name="sap.com" target-type="service">com.sap.aii.af.svc.facade</reference-target>
    </reference>
    <reference reference-type="hard">
    <reference-target provider-name="sap.com" target-type="interface">com.sap.aii.af.ifc.facade</reference-target>
    </reference>
    <reference reference-type="hard">
    <reference-target provider-name="sap.com" target-type="library">com.sap.aii.af.lib.facade</reference-target>
    </reference>
    <reference reference-type="hard">
    <reference-target provider-name="sap.com" target-type="library">com.sap.base.technology.facade</reference-target>
    </reference>
    <fail-over-enable mode="disable" />
    </application-j2ee-engine>
    EJB-J2EE-ENGINE.XML
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE ejb-j2ee-engine SYSTEM "ejb-j2ee-engine.dtd">
    <ejb-j2ee-engine>
    <enterprise-beans>
    <enterprise-bean>
    <ejb-name>GetMailAttachment</ejb-name>
    <jndi-name>GetMailAttachment</jndi-name>
    <session-props/>
    </enterprise-bean>
    </enterprise-beans>
    </ejb-j2ee-engine>
    EJB-JAR.XML
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans
    2.0//EN"
    "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
    <ejb-jar>
    <description>EJB JAR description</description>
    <display-name>EJB JAR</display-name>
    <enterprise-beans>
    <session>
    <ejb-name>GetMailAttachment</ejb-name>
    <home>com.sap.aii.af.lib.mp.module.ModuleHome</home>
    <remote>com.sap.aii.af.lib.mp.module.ModuleRemote</remote>
    <local-home>com.sap.aii.af.lib.mp.module.ModuleLocalHome</local-home>
    <local>com.sap.aii.af.lib.mp.module.ModuleLocal</local>
    <ejb-class>sample.GetMailAttachment</ejb-class>
    <session-type>Stateless</session-type>
    <transaction-type>Container</transaction-type>
    </session>
    </enterprise-beans>
    </ejb-jar>
    SENDER MAIL ADAPTER modules
    1 AF_Modules/PayloadSwapBean Local EB 1
    2 GetMailAttachment Local EB 2
    3 sap.com/com.sap.aii.adapter.mail.app/XIMailAdapterBean Local EB 3
    1     swap.keyName          payload-name
    1     swap.keyValue          MailAttachment-1
    RECEIVER FILE MODULES
    1     localejbs/AF_Modules/DynamicConfigurationBean     Local Enterprise Bean     1
    2     localejbs/CallSapAdapter                    Local Enterprise Bean     2
    1     key.0          write http://sap.com/xi/XI/System/File FileName
    1     value.0          message.interface
    VARIABLE FILENAME SUBST WITH ASMA TURNED ON
    fName     message:interface_name
    JAVA SOURCE
    package sample;
    import javax.ejb.CreateException;
    import javax.ejb.SessionBean;
    import javax.ejb.SessionContext;
    import com.sap.aii.af.lib.mp.module.Module;
    import com.sap.aii.af.lib.mp.module.ModuleContext;
    import com.sap.aii.af.lib.mp.module.ModuleData;
    import com.sap.aii.af.lib.mp.module.ModuleException;
    import com.sap.engine.interfaces.messaging.api.Message;
    import com.sap.engine.interfaces.messaging.api.MessagePropertyKey;
    import com.sap.engine.interfaces.messaging.api.TextPayload;
    import com.sap.engine.interfaces.messaging.api.XMLPayload;
    import com.sap.aii.af.service.cpa.Channel;
    @ejbHome <{com.sap.aii.af.lib.mp.module.ModuleHome}>
    @ejbLocal <{com.sap.aii.af.lib.mp.module.ModuleLocal}>
    @ejbLocalHome <{com.sap.aii.af.lib.mp.module.ModuleLocalHome}>
    @ejbRemote <{com.sap.aii.af.lib.mp.module.ModuleRemote}>
    @stateless
    <code>GetMailAttachment</code>
    @SuppressWarnings("unused")
    public class GetMailAttachment implements SessionBean, Module {
         private static final long serialVersionUID = 7612238514043673502L;
         private SessionContext myContext;
         private MessagePropertyKey myFileName;
         public void ejbRemove() {
         public void ejbActivate() {
         public void ejbPassivate() {
         public void setSessionContext(SessionContext context) {
              myContext = context;
    @throws CreateException
         public void ejbCreate() throws CreateException {
         public void getMessageProperty(MessagePropertyKey FileName) {
              myFileName = FileName;
    @param moduleContext
               Contains data of the module processor that might be important
               for the module implementation such as current channel ID
    @param inputModuleData
               Contains the input XI message as principal data plus eventual
               set supplemental data
    @return ModuleData Contains the (changed) output XI message. Might be the
            response message if the module is the last in the chain.
    @exception ModuleException
                   Describes the cause of the exception and indicates whether
                   an retry is sensible or not.
         @SuppressWarnings("deprecation")
         public ModuleData process(ModuleContext moduleContext,
                   ModuleData inputModuleData) throws ModuleException {
              try {
                   Message msg = (Message) inputModuleData.getPrincipalData();
                   TextPayload payload = msg.getDocument();
                   String contentType = payload.getContentType();
                   // Content Type could be something like
                   // text/plain;charset="UTF-8";name="file.txt"
                   contentType = contentType.replaceAll("\"", "");
                   int i = contentType.lastIndexOf("=") + 1;
                   String fileName = contentType.substring(i);
                   msg.setMessageProperty(myFileName, fileName);
                   inputModuleData.setPrincipalData(msg);
              } catch (Exception e) {
              return inputModuleData;
    JAVA ERRORS
    2009-02-04 11:41:14     Information     Mail: calling the module processor for channel LMK_Common_Mail_Sender
    2009-02-04 11:41:14     Information     Swap: swapping by payload-name ? MailAttachment-1
    2009-02-04 11:41:14     Information     Swap: successfully swapped
    2009-02-04 11:41:14     Information     Mail: message leaving the adapter (call)
    2009-02-04 11:41:14     Information     The application tries to send an XI message asynchronously using connection AFW.
    2009-02-04 11:41:14     Information     Backward validation is enabled
    2009-02-04 11:41:14     Error     Unable to validate the message with message ID 8702df71-f254-11dd-9b9b-001a64a73518
    2009-02-04 11:41:14     Error     Returning to application. Exception: com.sap.engine.interfaces.messaging.api.exception.MessagingException: Content is not allowed in prolog.
    2009-02-04 11:41:14     Error     Mail: error occured: com.sap.engine.interfaces.messaging.api.exception.MessagingException: Content is not allowed in prolog.
    2009-02-04 11:41:14     Error     Mail: error occured: com.sap.aii.af.lib.mp.module.ModuleException

  • What do I need to get the 6.7 update [to read the CR2 canon raw files] installed in Photoshop elements 10 [new computer with Windows 8]?

    I downloaded the zip file for the 6.7 update and unzipped it. I double clicked on the .exe file and it would not install. What do I need to get the update installed?

    Is this the 6.7 camera raw updater you tried?
    It's specifically for pse 10 on windows.
    Adobe - Photoshop Elements : For Windows : Camera Raw 6.7 update for Elements 10
    What camera do you have?

  • Need to get the overtime hours worked for Report

    Dear Experts,
    We have configured Overtime for client and it is working fine.
    But for custom report development we need to get the overtime hours worked.
    We have searched in B2 cluster and not able to identify exact overtime table.
    Request your suggestionsu2026u2026..

    Hi,
    after time elavualtion use t code PT66,  in this t.code double click on the each month(period) then you can get the internal table like ZES, SALDO, ZKO. again double click on the each internal table, you can get the information through the time types.  Like , now you want the overtime hours, 0903, 0904 with this time types you can get the each employee no. of. overtime hours.
    ZL, ZES, SALDO, TIP entries are internal table , you could not get any results from this table with using se11, se16.
    With PT_BAL00 with this report also we can get the overtime hours with the help of time events.
    Good luck
    Devi

  • I need to get the logs of my iPhone 5. I'm a registered as a developer and I have an issue with one of my app which is already in the market

    I need to get the logs of my iPhone 5. I'm a registered as a developer and I have an issue with one of my app which is already in the market

    The Firefox 3.5.x branch has reached end-of-life and is no longer maintained.<br />
    You will no longer receive security updates.<br />
    You can update Firefox via "Help > Check for Updates" or download and install the latest Firefox 3.6.x.<br />
    Firefox 4 and later require at least OS X 10.5 and an Intel Mac.
    * http://www.mozilla.com/firefox/4.0/system-requirements/
    If you have problems with updating or with the permissions then easiest is to download the full version and trash the currently installed version to do a clean install of the new version.
    Download a new copy of the Firefox program and save the DMG file to the desktop
    * Firefox 3.6.x: http://www.mozilla.com/en-US/firefox/all-older.html
    * Trash the current Firefox application to do a clean (re-)install
    * Install the new version that you have downloaded
    Your profile data is stored elsewhere in the [http://kb.mozillazine.org/Profile_folder_-_Firefox Firefox Profile Folder], so you won't lose your bookmarks and other personal data.

  • Need to get the exact time of each picture that I saved ( maybe as a excel sheet or word )

    Hi guys,
    I am actually a new labview user. I have successfullly been able to save pictures. But unfortunately I got two problems. The first one is that I need to use two cameras at the same time. The program I have so far is for one camera. The second problem is that I need to get the exact time for each picture saved in the profile.
    I would appreciate if someone can help me with that. Anyway plz find attached the subvi.
    Regards,
    Abbas
    Attachments:
    Abbas progress.vi ‏54 KB

    Hi Abbas,
    First, I notice that you are using IMAQ for USB.  Is there any particular reason you are not using IMAQdx?  This is the newer, supported driver for use with USB cameras that supports acquiring from multiple cameras at the same time. 
    Check these two articles:
    Can I Acquire from Multiple USB Cameras Simultaneously Using IMAQdx?
    Can I Acquire from Two USB Cameras Simultaneously with NI-IMAQ for USB Cameras 1.0?
    And also this example (if you camera does not support acquiring from multiple cameras at the same time):
    Toggle Between Multiple USB Cameras
    As for timestamps, some cameras output them with the frame timing.  However, usually this is not a feature of USB cameras; if it is not, you can look into timing options within LabVIEW.  Try playing with the property node for IMAQdx and the Acquisition Attributes.
    Cheers,
    Marti C
    Applications Engineer
    National Instruments
    NI Medical

  • Need to get the number of messages displayed

    Dear All,
    I need to know whether the message area is having any messages or not. If messages are there then i need to get the exact number of the messages. I found the count in the class CL_WDR_MESSAGE_AREA. But the count is the private attribute. Is there any methods available to get the count of the number of mesages.
    Thanks & Regards,
    Raghuram K.R.

    Hi raghuram
    below is the code snippet to get the count of message displayed ..
    other than this what is your looking for Exactly. pls be clear so that we can help you out .
    *   get message manager
      DATA lo_api_controller     TYPE REF TO if_wd_controller.
      DATA lo_message_manager    TYPE REF TO if_wd_message_manager.
      DATA :lt_messages_mgr TYPE if_wd_message_manager=>ty_t_messages,
            lv_string1 TYPE string ,
            lv_string2 TYPE string,
            lv_count TYPE i .
    *Message Manager Reference  
      lo_api_controller ?= wd_this->wd_get_api( ).
      lo_message_manager = lo_api_controller->get_message_manager( ).
    *   report 2  message
      lv_string1 = lo_message_manager->report_success( message_text  = 'test 1').
      lv_string2 = lo_message_manager->report_success( message_text  = 'test 2').
    *  get the list of message
      lt_messages_mgr = lo_message_manager->get_messages( ).
    *  count the no of message
      DESCRIBE TABLE lt_messages_mgr LINES lv_count.
    Regards
    Chinnaiya P
    Edited by: chinnaiya pandiyan on Oct 19, 2011 1:17 PM

  • I was on iTunes on my computer trying to drag a song from my iPhone 4 to my computer but when I connected my phone to the computer using a USB cable then it said that it couldn't connect to my phone because I need to get the later version of iTunes. How?

    I was on iTunes on my computer trying to drag a song from my iPhone 4 to my computer but when I connected my phone to the computer using a USB cable then it said that it couldn't connect to my phone because I need to get the later version of iTunes. How do I do that?

    Hi Soccer4461,
    If you need to update your iTunes software, you may find the following article helpful:
    OS X: Updating OS X and Mac App Store apps
    http://support.apple.com/kb/ht1338
    Regards,
    - Brenden

  • EXPECTED OUTPUT:   here i need to get the count of 932 + 134 records = 1064

    Hi Team,
    could you pls suggest y iam getting wrong count.
    select * from i_invoice_info_t_log_v invlog,invoice_header_t invhead
    WHERE substr(invlog.tot_cust_no,1,7)=substr(invhead.acct_no,3,7)--------comparing tot_cust_no and acct_no for the other countries
    and invhead.comp_code NOT in (2300) ----here when iam running this query i am getting the count of 932 records.
    select * from i_invoice_info_t_log_v invlog,invoice_header_t invhead
    where substr(invlog.tot_cust_no,3,7)=to_char(substr(invhead.acct_no,3,7))--------------comparing tot_cust_no and acct_no FOR THE COUNTRY 2300
    and invhead.comp_code in (2300) ----Here when i am running this query i am getting the count of 134 records.
    EXPECTED OUTPUT:   here i need to get the count of 932 + 134 records = 1064 records.
    I am  using this query like below:
    select * from  i_invoice_info_t_log_v invlog,invoice_header_t invhead
    where
    (substr(invlog.tot_cust_no,1,7)=substr(invhead.acct_no,3,7)
               and invhead.comp_code NOT in (2300)
              OR
              (substr(invlog.tot_cust_no,3,7)=to_char(substr(invhead.acct_no,3,7))
               and invhead.comp_code in (2300)
    )---------------------------------------------------here when i am running this query i am getting the count of  18381 records which is incorrect.
    Expected output: i need to get the data for the comp_code which are not in 2300 and which are in 2300... both

    select  *
      from  i_invoice_info_t_log_v invlog,
            invoice_header_t invhead
      WHERE    (
                    substr(invlog.tot_cust_no,1,7) = substr(invhead.acct_no,3,7) --comparing tot_cust_no and acct_no for the other countries
                and
                    invhead.comp_code NOT in (2300) --here when iam running this query i am getting the count of 932 records.
            or (
                    substr(invlog.tot_cust_no,3,7) = to_char(substr(invhead.acct_no,3,7)) --comparing tot_cust_no and acct_no FOR THE COUNTRY 2300
                and
                    invhead.comp_code in (2300) --Here when i am running this query i am getting the count of 134 records.
    /SY.

  • I need to get the Current System Date and time in the format

    I need to get the Current System Date and time in the format
    *6/24/2009 11:30:29 AM*
    How do i do it ?

    I seem to be saying this a lot lately.
    Google is your friend.
    I googled "java current date format" and SimpleDateFormat featured prominently in the results.

Maybe you are looking for