Read XML attributes from RSS internet link

I am very new to LabVIEW, and I am trying to determine the best way to read information an RSS link. Specfically, I would like to read data from a Yahoo! Weather RSS like http://weather.yahooapis.com/forecastrss?w=2502265. I would like to extract the temperature from <yweather: condition temp="[##]>, the wind speed from <yweather:wind speed="[##]">, and the text description from <yweather:condition text="[text]".
I have looked into some XML parsing solutions like EasyXML, but I wonder if they are too much for what may be a simple task. I would appreciate any input on my current problem. Thanks.

Howdy,
It looks like EasyXML would make you life a little easier. You can search the LabVIEW Example Finder (Help menu->Find Examples) for XML examples. Other than that you would have to navigate to the website and parse the website source and use the LabVIW String Functions.
Joshua B.
National Instruments
NI Services
NI Support Resources
NI Training Resources

Similar Messages

  • Read XML file from presentation server

    Hi All,
    I want read XML file from presentation server currently i am using GUI_UPLOAD fm . but it is reading some junk data.
    DATA : BEGIN OF upl OCCURS 0,
              f(255) TYPE c,
           END OF upl.
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename = D:\XX.XML'
          filetype = 'BIN'
        TABLES
          data_tab = upl.
    is there any other alternative.
    Thanks
    Swarup,

    Hi Swarup,
    Use method IMPORT_FROM_FILE of class CL_XML_DOCUMENT.
    A sample code snippet :-
    PARAMETERS: p_filnam TYPE localfile OBLIGATORY
    DEFAULT 'C:\Documents and Settings\ssaha\Desktop\test.xml'.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_filnam.
    DATA: l_v_fieldname TYPE dynfnam.
    l_v_fieldname = p_filnam.
    CALL FUNCTION 'F4_FILENAME'
    EXPORTING
    program_name = syst-cprog
    dynpro_number = syst-dynnr
    field_name = l_v_fieldname
    IMPORTING
    file_name = p_filnam.
    START-OF-SELECTION.
    TYPES:
    BEGIN OF ty_tab,
    name TYPE string,
    value TYPE string,
    END OF ty_tab.
    DATA:
    lcl_xml_doc TYPE REF TO cl_xml_document,
    v_subrc TYPE sysubrc,
    v_node TYPE REF TO if_ixml_node,
    v_child_node TYPE REF TO if_ixml_node,
    v_root TYPE REF TO if_ixml_node,
    v_iterator TYPE REF TO if_ixml_node_iterator,
    v_nodemap TYPE REF TO if_ixml_named_node_map,
    v_count TYPE i,
    v_index TYPE i,
    v_attr TYPE REF TO if_ixml_node,
    v_name TYPE string,
    v_prefix TYPE string,
    v_value TYPE string,
    v_char TYPE char2.
    DATA:
    itab TYPE STANDARD TABLE OF ty_tab,
    wa TYPE ty_tab.
    CREATE OBJECT lcl_xml_doc.
    CALL METHOD lcl_xml_doc->import_from_file
    EXPORTING
    filename = p_filnam
    RECEIVING
    retcode = v_subrc.
    CHECK v_subrc = 0.
    v_node = lcl_xml_doc->m_document.
    CHECK NOT v_node IS INITIAL.
    v_iterator = v_node->create_iterator( ).
    v_node = v_iterator->get_next( ).
    WHILE NOT v_node IS INITIAL.
    CASE v_node->get_type( ).
    WHEN if_ixml_node=>co_node_element.
    v_name = v_node->get_name( ).
    v_nodemap = v_node->get_attributes( ).
    IF NOT v_nodemap IS INITIAL
    * attributes
    v_count = v_nodemap->get_length( ).
    DO v_count TIMES.
    v_index = sy-index - 1.
    v_attr = v_nodemap->get_item( v_index ).
    v_name = v_attr->get_name( ).
    v_prefix = v_attr->get_namespace_prefix( ).
    v_value = v_attr->get_value( ).
    ENDDO.
    ENDIF.
    WHEN if_ixml_node=>co_node_text OR
    if_ixml_node=>co_node_cdata_section.
    * text node
    v_value = v_node->get_value( ).
    MOVE v_value TO v_char.
    IF v_char <> cl_abap_char_utilities=>cr_lf.
    wa-name = v_name.
    wa-value = v_value.
    APPEND wa TO itab.
    CLEAR wa.
    ENDIF.
    ENDCASE.
    * advance to next node
    v_node = v_iterator->get_next( ).
    ENDWHILE.
    LOOP AT itab INTO wa.
    ENDLOOP.
    Regards
    Abhii

  • Function module to read xml files from application server

    Hi experts,
            I need to read  xml files from application server to sap. Is the any siutable function moldule for that?

    Hi Cenosure,
    Donno about FM which will upload data directly to SAP, I think you have to do some mapping for it so that it will suit the SAP format. Again it depends on your requirement..
    Please elaborate more about your requirement.
    Please have a look on below FM
    TEXT_CONVERT_XML_TO_SAP
    Also search on SCN there are many threads on the same topic available.
    http://abapreports.blogspot.com/2008/09/upload-xml-file-from-application-server.html
    This is the link which will give you the Code
    http://www.geocities.com/rmtiwari/Resources/MySolutions/Dev/Codes/Report/Z_RMTIWARI_XML_TO_ABAP_46C.html
    Use this XML file to Upload the same, this Program will work for your XML file also,
    http://www.geocities.com/rmtiwari/Resources/MySolutions/Dev/Codes/Report/input_xml.xml
    See the below thread also
    Upload XML to internal table and vice versa in SAP 4.6C
    Hope it will solve your problem..
    Thanks & Regards
    ilesh 24x7
    ilesh Nandaniya

  • FM to read XML files from Application server in ECC5.0

    Hi All,
    We need to pick up an XML file from Application server/FTP server. The requirement is to parse the XML file and process it to create material master. SAP provides standard function modules to read XML files.
    Now we need to read the XML file contents of MM01 and upload into SAP Data Base through BAPI
    I need to know about the Function modules to read XML files from Application Server and also about the FM's that will update the Date base tables with the data obtained form XML files.
    Regards
    Prathima

    Parsing XML data:
    http://help.sap.com/saphelp_nw04/helpdata/en/86/8280ba12d511d5991b00508b6b8b11/frameset.htm
    or alternatively check out ABAP online help for "CALL TRANSFORMATION".
    For creating the material master look at BAPI_STANDARDMATERIAL_CREATE.
    Thomas

  • Is there any way to read XML directly from a Web Page ??

    i have a url, which on sending request, shows XML in browser.
    Now i need to read this XML in browser and then manipulate it according to my need and display it on another page.
    actually the process is. :
    1) i have to first retrieve an xml from other site. (XML will only be shown in browser)
    2.)then i have to read the Xml and show it in according to my requirements.
    Is there any way to read XML directly from a Web Page ??
    is their logic to accomplish this.
    e.g in Servlet i can do somewhat like this :
    String wholeXml=Somemethod(url);
    Please Advice

    the average Java XML parser will accept an InputStream, so just open an URLConnection to the webpage, get the inputstream from it and feed that inputstream to the XML parser. If the URL has valid XML data, it will get parsed without problems.

  • Reading XML file from application server and  put into internal table-4.6C

    Dear All,
    Is there any way of reading XML file from application server to SAP? I am using 4.6C. Function module SCMS_STRING_TO_XSTRING function module is not available. Please suggest.
    Thanks and regards,
    Atanu

    Hi Atanu!
    Simply use the XSLT transformation 'ID'.
    FIELD-SYMBOLS <ls_result> TYPE ANY.
    CREATE DATA lref_data TYPE (your_structure).
    ASSIGN lref_data->* TO <ls_result>.
    CALL TRANSFORMATION id
                        SOURCE XML xmlstr
                        RESULT result = <ls_result>.
    "xmlstr" contains your XML file. Just read it into it via standard I/O operations. "<ls_result>" will contain your DDIC formatted content.
    Best regards
    Torsten

  • Problem  while reading XML file from Aplication server(Al11)

    Hi Experts
    I am facing a problem while  reading XML file from Aplication server  using open data set.
    OPEN DATASET v_dsn IN BINARY MODE FOR INPUT.
    IF sy-subrc <> 0.
        EXIT.
      ENDIF.
      READ DATASET v_dsn INTO v_rec.
    WHILE sy-subrc <> 0.
      ENDWHILE.
      CLOSE DATASET v_dsn.
    The XML file contains the details from an IDOC number  ,  the expected output  is XML file giving  all the segments details in a single page and send the user in lotus note as an attachment, But in the  present  output  after opening the attachment  i am getting a single XML file  which contains most of the segments ,but in the bottom part it is giving  the below error .
    - <E1EDT13 SEGMENT="1">
      <QUALF>001</QUALF>
      <NTANF>20110803</NTANF>
      <NTANZ>080000</NTANZ>
      <NTEND>20110803<The XML page cannot be displayed
    Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
    Invalid at the top level of the document. Error processing resource 'file:///C:/TEMP/notesD52F4D/SHPORD_0080005842.xml'.
    /SPAN></NTEND>
      <NTENZ>000000</NTENZ>
    for all the xml  its giving the error in bottom part ,  but once we open the source code and  if we saved  in system without changing anything the file giving the xml file without any error in that .
    could any one can help to solve this issue .

    Hi Oliver
    Thanx for your reply.
    see the latest output
    - <E1EDT13 SEGMENT="1">
      <QUALF>003</QUALF>
      <NTANF>20110803</NTANF>
      <NTANZ>080000</NTANZ>
      <NTEND>20110803</NTEND>
      <NTENZ>000000</NTENZ>
      <ISDD>00000000</ISDD>
      <ISDZ>000000</ISDZ>
      <IEDD>00000000</IEDD>
      <IEDZ>000000</IEDZ>
      </E1EDT13>
    - <E1EDT13 SEGMENT="1">
      <QUALF>001</QUALF>
      <NTANF>20110803</NTANF>
      <NTANZ>080000</NTANZ>
      <NTEND>20110803<The XML page cannot be displayed
    Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
    Invalid at the top level of the document. Error processing resource 'file:///C:/TEMP/notesD52F4D/~1922011.xml'.
    /SPAN></NTEND>
      <NTENZ>000000</NTENZ>
    E1EDT13 with QUALF>003 and  <E1EDT13 SEGMENT="1">
    with   <QUALF>001 having almost same segment data . but  E1EDT13 with QUALF>003  is populating all segment data
    properly ,but E1EDT13 with QUALF>001  is giving in between.

  • Reading XML Data from ABAP Program?

    Hi,
    How do I read XML Data from an ABAP Program? For example if I have the below basic XML Code-
    <xml>
    <Name> Thiru </Name>
    <Age> 24 </Age>
    <City> chennai </Chennai>
    </xml>
    How do i read the data within the Name,Age, and City tags into variables in the ABAP Program?
    Regards,
    Thiru

    if you decide to do in XSLT, I have a sample list here:
    XML file like this:
    <?xml version="1.0" encoding="UTF-16"?>
    <F>
    <P1>
    <t_1>value1</t_1>
    <t_2>testvalue</t_2>
    </P1>
    <P2>
    </P2>
    </F>
    XSLT file like this:
    <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sapxsl="http://www.sap.com/sapxsl" version="1.0">
    <xsl:strip-space elements="*"/>
    <xsl:template match="F">
    <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
    <asx:values>
    <<b>DOCUMENT</b>>
    <xsl:apply-templates/>
    </<b>DOCUMENT</b>>
    </asx:values>
    </asx:abap>
    </xsl:template>
    <xsl:template match="P1">
    <ENTRY>
    <<b>T_1</b>><xsl:value-of select="t_1"/></T_1>
    <<b>T_2</b>><xsl:value-of select="t_2"/></T_2>
    </ENTRY>
    </xsl:template>
    </xsl:transform>
    ABAP program like this:
    DATA: BEGIN OF wa_upload,
    text(255) TYPE c,
    END OF wa_upload,
    itab_upload LIKE TABLE OF wa_upload,
    BEGIN OF wa_document,
    t_1 TYPE string,
    t_2 TYPE string,
    END OF wa_document,
    itab_document LIKE TABLE OF wa_document.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = 'XXXXX'
    filetype = 'ASC'
    TABLES
    data_tab = itab_upload.
    CALL TRANSFORMATION zrappel_xml_test
    SOURCE XML itab_upload
    RESULT <b>document</b> = itab_document.
    You should pay attention to the bold words.
    hope it will be helpful
    thanks

  • Reading XML file from UNIX

    I am reading XML file from unix using :
    FORM read_file USING p_name.
      DO.
        READ DATASET p_name INTO WXML_LINE LENGTH LENG.
      ENDDO.
    Then I am using subroutine below where I get a short dump at
      case X_NODE->get_type( ).
    FORM get_data tables   Y_CAPXML   structure GV_CAPXML
                  using value(x_node) type ref to if_ixml_node.
      data: INDENT      type i.
      data: PTEXT       type ref to if_ixml_text.
      data: STRING      type string.
      data: TEMP_STRING(100).
      case X_NODE->get_type( ).
        when if_ixml_node=>co_node_element.
          STRING = X_NODE->get_name( ).
          GV_NODETEXT = STRING.
        when if_ixml_node=>co_node_text.
          PTEXT ?= X_NODE->query_interface( IXML_IID_TEXT ).
          if PTEXT->ws_only( ) is initial.
            STRING = X_NODE->get_value( ).
            case GV_NODETEXT.
              when 'NIIN'.
                move STRING to GV_CAPXML-NIIN.
              when 'FED_x0020_STOCK_x0020_CLASS'.
                move STRING to GV_CAPXML-fed_stock_class.
              when 'DODIC'.
                move STRING to GV_CAPXML-dodic.
             endcase.
    The text for the short dump is : STACK_STATE_NO_ROLL_MEMORY
    Can someone please explain what is it mean.
    Thanks.

    May be this blog can help:
    <a href="/people/r.eijpe/blog/2005/11/21/xml-dom-processing-in-abap-part-ii--convert-an-xml-file-into-an-abap-table-using-sap-dom-approach for Blog</a>
    Sri

  • How to read .xml file from embedded .swf(flash output) in captivate

    I have been trying to read .xml file from the .swf (Flash output) that is embedded within the captivate file but no luck yet . Please if anyone got any clue on how get this thing done using Action script 3.0 then let me know. I am using Adobe Captivate 5.5 at present and Flash CS 5.5.
    I am well aware about how to read .xml file through action script 3.0 in flash but when insert the same flash in captivate and publish nothing comes in captivate output. I would higly appreciate if anyone could help me out with that.
    Here is is graphical demonstration of my query :
    Message was edited by: captainmkv

    Hi Captainmkv,
    Does the information in this post cover what you're trying to do: http://forums.adobe.com/message/5081928#5081928
    Tristan,

  • I want to make a schedular which read xml files from a folder ,import in Indesign template then export as a pdf....

    i want to make a schedular probably in Coldfusion or using javascript ,  which read xml files from a folder ,import in Indesign template then export as a pdf....

    I don't think you understand: I want to open Dreamweaver and build a brand new site, then when I am done I want to host the dreamweaver site on the Business Catalyst platform. I dont want to use anything in BC to build the site, I just want to use the hosting platform. I do not want to import a BC site into dreamweaver or anything like that. I just want to use BC the same way I would use godaddy, or uhost or any other hosting provider. Based on your response you said that "of course its possible to build a BC site in Dreamweaver" I dont want to build a BC site, I want to build a Dreamweaver site and host it on the BC platform. Like I said before it doesnt seem like this is possible. As of now we can only build a new site in MUSE and integrate it into BC without using a BC template. Can you understand what I am saying. I DONT WANT TO USE A BC TEMPLATE, I WANT NOTHING TO DO WITH BC WHILE I AM BUILDING THE SITE WITH DREAMWEAVER, JUST LIKE MUSE DOES.

  • I want to use ODI to read XML messages from JMS queue and then process it..

    I want to use oracle ODI (Oracle Data Integrator) to read XML messages from JMS queue and then process it.. i also want to process and validate the data in it....
    Could anyone please tell me the steps to achieve the same. I tried some ways which i got on OTN, but not able to implement it exactly...
    As i m very new to ODI, it will be great if you provide detailed steps..
    Thanks in advance for your help....

    Hi,
    Were you able to do it? We are facing this same issue now and, despite the fact the docs say otherwise, it does not seem to be a trivial task.
    TIA,
    Tedi

  • Reading XML File from application server

    Hi experts,
    My aim is to read a XML file from application server and extract the relevant data from it and process further.
    When I am trying to read a XML file from application server it is reading success fully but the problem is that its not reading the last root structure of XML file why is so happening can any body help me?
    I am using the following code:
    TYPES: BEGIN OF xml_line,
    text(256) type x,
    END OF xml_line.
    DATA: e_file LIKE rlgrap-filename VALUE  'applcatin server path'
    OPEN DATASET e_file FOR INPUT IN BINARY MODE.
    IF sy-subrc EQ 0.
      DO.
        READ DATASET e_file INTO wa_item1-text.
        IF sy-subrc EQ 0.
          APPEND wa_item1 TO gt_item1 .
          CLEAR wa_item1.
        ELSE.
          EXIT.
        ENDIF.
      ENDDO.
    ENDIF.
    CLOSE DATASET e_file.
    after this i am passing this internal table to "cl_ixml" class to extract the data
    but it returning the itab with required value except the last record.
    The stream reading the file it self is i thought in complete thats why it is not converting the all values.
    Please  help me...
    Thanks a ton in advance.

    Hi,
    1 Copy Report BCCIIXMLT1
    2 (you can change the way of filling internal table xml_table if necessary)
    3 you don't need the part between
    *-- render the DOM back into an output stream/internal table
    and
    *-- print the whole DOM tree as a list...
    Comment it out or simply delete it
    4 Rename form print_node to your liking e.g. process_node
    5 In your new form you need three extra variables:
    data: attribs type ref to IF_IXML_NAMED_NODE_MAP,
          attrib_node type ref to IF_IXML_NODE,
          attrib_value type string.
    6 After the lines:
    when if_ixml_node=>co_node_element.
      string = pNode->get_name( ).
    Insert:
    attribs = pNode->get_attributes( ).
    clear attrib_value.
    case string.
      when ''. "put your XML tag name here
        attrib_node = attribs->get_named_item(name = '' ). "put your XML attribute name here
        attrib_value = attrib_node->get_value( ).
    You can also refer link,
    /people/r.eijpe/blog/2005/11/21/xml-dom-processing-in-abap-part-ii--convert-an-xml-file-into-an-abap-table-using-sap-dom-approach
    thanks & regards
    shreemohan

  • Help needed reading xml attributes

    I have a method that is reading through my XML doc and pulling out all of the elements. I want to get it to pull out the href attribute from within AdvertText but can't figure out how to do it within my method. Any help would be greatly appreciated!
    Here is the sample of the xml:
    <Advert groupName="Advert" type="group">
    <AdvertText dataType="RawString" fieldName="AdvertText" href="http://boston.craigslist.org/nos/abo/583827823.html" originalElement="a" type="field">First Floor Central Gloucester -</AdvertText>
    <Cost dataType="RawString" fieldName="Cost" href="http://boston.craigslist.org/nos/abo/583827823.html" originalElement="a" type="field">1350</Cost>
    <NumberOfBedrooms dataType="RawString" fieldName="NumberOfBedrooms" href="http://boston.craigslist.org/nos/abo/583827823.html" originalElement="a" type="field">3</NumberOfBedrooms>
    <Location dataType="RawString" fieldName="Location" originalElement="span" type="field">Gloucester</Location>
    </Advert>
    Here is my method:
    public Vector Read() {
            try {
                DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
                DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
                Document doc = docBuilder.parse("http://www.dapper.net/RunDapp?dappName=CraigslistRentInfo&v=1&applyToUrl=http%3A%2F%2Fboston.craigslist.org%2Faap?query=&minAsk=min&maxAsk=max&bedrooms=1");
                // normalize text representation
                doc.getDocumentElement ().normalize ();
                System.out.println ("Root element of the doc is " +
                     doc.getDocumentElement().getNodeName());
                NodeList listOfAdverts = doc.getElementsByTagName("Advert");
                int totalAdverts = listOfAdverts.getLength();
                System.out.println("Total no of people : " + totalAdverts);
                RentAdvert myAd;
                String text;
                String loc;
                String bed;
                String cost;
                int y=10;
                for(int i=0; i<y ; i++){
                    Node firstAdvertNode = listOfAdverts.item(i);
                    if(firstAdvertNode.getNodeType() == Node.ELEMENT_NODE){
                        Element firstAdvertElement = (Element)firstAdvertNode;
                        NodeList advertTextList = firstAdvertElement.getElementsByTagName("AdvertText");
                        if((Element)advertTextList.item(0)==null){
                            text = "not available";
                        }else{
                        Element advertTextElement = (Element)advertTextList.item(0);
                        NodeList textATList = advertTextElement.getChildNodes();
                        System.out.println("Advert Text : " + ((Node)textATList.item(0)).getNodeValue().trim());
                        text = ((Node)textATList.item(0)).getNodeValue().trim();
                        //myAd.setAdvertText(text);
                        NodeList costList = firstAdvertElement.getElementsByTagName("Cost");
                        if((Element)costList.item(0)==null){
                            cost = "not available";
                        }else{
                        Element costElement = (Element)costList.item(0);
                        NodeList textCList = costElement.getChildNodes();
                        System.out.println("Cost : " + ((Node)textCList.item(0)).getNodeValue().trim());
                        cost = ((Node)textCList.item(0)).getNodeValue().trim();
                        //myAd.setCost(cost);
                        NodeList numberOfBedroomsList = firstAdvertElement.getElementsByTagName("NumberOfBedrooms");
                        if((Element)numberOfBedroomsList.item(0)==null){
                            bed = "not available";
                        }else{
                        Element numberOfBedroomsElement = (Element)numberOfBedroomsList.item(0);
                        NodeList textNOBList = numberOfBedroomsElement.getChildNodes();
                        System.out.println("Number of Bedrooms : " + ((Node)textNOBList.item(0)).getNodeValue().trim());
                        bed = ((Node)textNOBList.item(0)).getNodeValue().trim();
                        //myAd.setNumberOfBedrooms(bed);
                        NodeList locationList = firstAdvertElement.getElementsByTagName("Location");
                        if((Element)locationList.item(0)==null){
                            loc = "not available";
                        }else{
                        Element locationElement = (Element)locationList.item(0);
                        NodeList textLList = locationElement.getChildNodes();
                        System.out.println("Location : " + ((Node)textLList.item(0)).getNodeValue().trim());
                        loc = ((Node)textLList.item(0)).getNodeValue().trim();
                        //myAd.setLocation(loc);
                        if((text!="not available")&&(cost!="not available")&&(bed!="not available")&&(loc!="not available")){
                        myAd = new RentAdvert(text,cost,bed,loc);
                        listings.add(i,myAd);
                        }else{
                            y++;                       
                    }//end of if clause           
                }//end of for loop with s var
            }catch (SAXParseException err) {
            System.out.println ("** Parsing error" + ", line "
                 + err.getLineNumber () + ", uri " + err.getSystemId ());
            System.out.println(" " + err.getMessage ());
            }catch (SAXException e) {
            Exception x = e.getException ();
            ((x == null) ? e : x).printStackTrace ();
            }catch (Throwable t) {
            t.printStackTrace ();
            return listings;
        }//end of Read

    Works!
    NamedNodeMap a;
    a = n.getAttributes();
                    if(a != null) {
                    System.out.println("AttributesList: " + a);
                    System.out.println("NodeValue: " + a.item(0).getNodeValue());

  • Read XML attributes

    I have this xml.
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <root>
         <file name="Bohy" type="folder">
              <file name=".dropbox" type="file" />
              <file name="Beck" type="folder">
                   <file name="desktop.ini" type="file" />
              </file>
         </file>
         <file name="Links.txt" type="file" />
         <file name="Pipo" type="folder">
         </file>
    </root>And I need read attributes name and type, but with my code is not works. Can you repair me. Thanks
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.NamedNodeMap;
    import org.w3c.dom.Node;
    import org.w3c.dom.NodeList;
    * @author thomas lokol
    public class Main {
         private static DocumentBuilderFactory dbf;
         private static DocumentBuilder builder;
         private static Document doc;
          * @param args
         public static void main(String[] args) {
              createDocuments();
              // Root element
              Node node = doc.getDocumentElement();
              String rootElement = node.getNodeName();
              System.out.println("Root element: " + rootElement);
              readNodes(node.getChildNodes());
         private static void readNodes(NodeList nodeList) {
              System.out.println(nodeList.getLength());
              for (int i = 0; i < nodeList.getLength(); i++) {
                   Node node = nodeList.item(i);
                   if (node.getNodeType() == Node.ELEMENT_NODE) {
                        Element element = (Element)node;
                   if(node.getNodeType() == Node.TEXT_NODE) {
                         NamedNodeMap attributes = node.getAttributes();
                         // Here is problem ...
                         for (int a = 0; a < attributes.getLength(); a++) {
                           Node theAttribute = attributes.item(a);
                           System.out.println(theAttribute.getNodeName() + "=" + theAttribute.getNodeValue());
         private static void createDocuments() {
              try {
                   dbf = DocumentBuilderFactory.newInstance();
                   builder = dbf.newDocumentBuilder();
                   doc = builder.parse("myFile.xml");
              } catch (Exception e) {
                   System.out.println("Chyba pri vytvareni");
                   e.printStackTrace();
    }Edited by: EJP on 23/04/2012 11:43: added {noformat}{noformat} tags. Please use them. Also fixed your title.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Hi,
    I would suggest that you use a more simple library like Dom4j,
    It is quite easy to use and is proven to have good performance on heavy tasks.
    you can access xml attributes with a single line cod :
    String value = element.attributeValue("Attribute name");you can download and view samples here : http://dom4j.sourceforge.net/

Maybe you are looking for

  • Adobe Premiere Elements 12 downloaded and bought on windows computer, transferable to a mac?

    I'm about to buy Adobe Premiere Elements 12 on my windows computer. Can I transfer the licens for this, and other Adobe products, to a new mac computer? Or are the licenses valid on all platforms? What do I have to do to prepare before? I've read/hea

  • Aspect Ratio in Quicktime

    I have been creating a showreel of work in iDVD6. It has all been going swimmingly, except that the Quicktime Movies that I have exported from FCP and imported into iDVD, which are 16:9, are coming out squashed 4:3 (i.e square pixels. The menu and su

  • Not able to deploy HPCM application

    Hi Gurus, we are using version 11.1.2.2 and we have created an application in HPCM and when we validate the same it shows successful but when we try to deploy it it throws below error Process Name : Thread : 0 Server : Detail : Initiating Product Act

  • Set user inherit permissions check box using powershell

    Hi All, How can I set the the  "include inherit permissions from this objects parent" propertiy in Active Directory user object to a list of users using powershell. This option is not checked for some of my users and I'll like to set it using a power

  • What font works best for Hindi titles in Premiere Pro CC 2014?

    I'm attempting to subtitle a video in Hindi. I've installed a few fonts but nothing is working 100%. When I copy/paste from a translated script (PDF) random characters do not show up in the title tool (they appear as spaces). I'm wondering if Adobe r