Reading the Attributes

Hi,
I have an xml file like the following
<?xml version="1.0" encoding="UTF-8" ?>
- <rapidtrade>
- <main webservice="VERMONT" applicationname="rapidtrade.exe" profilenumber="08" daystokeeporderstatus="15" supplier="Vermont" version="31821539">
  <computers />
- <configuration>
- <accounts>
  <account branch="0" number="8" name="NEVADA INDUSTRIAL SUPPLIES" vat="14" />
  </accounts>
- <Options>
  <variable name="changeshipping" value="1" />
  <variable name="forcepricechange" value="1" />
  <variable name="changeprice" value="0" />
  <variable name="webaddress" value="http://196.31.215.37:80/rapidtrade/vermont/rapidtrade.aspx" />
  <variable name="detaillogs" value="false" />
  <variable name="key" value="FKOFFGFG3FFHFFDFLK3IG" />
  </Options>
  </configuration>
  </main>
  </rapidtrade>is this my XML file, i want to read the node eg Options and its attributes.
Can any one help me...if u have some sample code pls do post it.
this is my code so far:
public static boolean Load(String webService,String profileID){
       // add the variables here untill the classes have been created
           try {
               // Create instance of DocumentBuilderFactory
                DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                // Get the DocumentBuilder
                DocumentBuilder builder = factory.newDocumentBuilder();
               Document document;
               Element root;
               // parse the XML file to be edited
               File file = new File( "C:\\Globals.XML" );
               // open xml file and get the root node
               document = builder.parse( file );
               root = document.getDocumentElement();
               //Find the main node then get options node under it, then load all variables
               NodeList List = document.getElementsByTagName("main");
               String projectNum;
               Node node;
               System.out.println(List.getLength());
               for(int i=0;i<List.getLength();i++){
                   node=List.item(i);
                   Element element = ( Element )node;
                   //if this is our service then load all the global variables
                   if( element.getAttribute("webservice").equals(webService) ){
                       if(element.getAttribute("profilenumber").equals(profileID)){
                           System.out.println( "\twebservice Attribute: " + element.getAttribute( "webservice" ) );
                           System.out.println( "\tprofileId Attribute: " + element.getAttribute( "profilenumber" ) );
                           Element elOptions = (Element)element.getElementsByTagName("Options").item(0);
                           System.out.println( "\tprofileId Attribute: " + element.getElementsByTagName("Options").item(0) );
                        //  Element elOptions = (Element)node;
                           //i'm stuck here
           } catch (Exception e){
               System.out.println("Error could not find a main node" + e.getMessage());
               return false;
           return true;
    public static void main(String[] args) {
      if (clsGlobal.Load("VERMONT","08")){
             System.out.print( "Project loaded");
         } else {
             System.out.print("Error");
    }thanks in advance
JoJo

DOM elements have an attribute method that returns the attributes.
See http://www.mozilla.org/docs/dom/domref/dom_el_ref.html
� {�                                                                                                                                                                                                                                                                                       

Similar Messages

  • How to read the attribute of the xml file using jaxb

    Thanks,
    Buddy as i have a issue i have to read the xml file using jaxb and xml file contains this data and i have read the attribute like name , desc and action for a particular menu name pls tell the code how to do this it will be a great favour to me
    thanx in advance
    Rasool
    <contextmenu>
    <menu name='Lead' >
    <menuitem name='newlead' desc='New Lead' action='/leads.do?dispatch=insert' />
    <menuitem name='editlead' desc='Edit Lead' action='' />
    <menuitem name='leadinfo' desc='Lead Information' action='' />
    </menu>
    <menu name='Cases' >
    <menuitem name='' desc='' action='' />
    <menuitem name='' desc='' action='' />
    <menuitem name='' desc='' action='' />
    </menu>
    <menu name='Contact' >
    <menuitem name='' desc='' action='' />
    <menuitem name='' desc='' action='' />
    <menuitem name='' desc='' action='' />
    </menu>
    </contextmenu>

    What my program do is to get the encoding of XML files and convert them to UTF-8 encoding files, while I need this "encoding" information of the original XML document thus I can convert...
    After reading specifications and JDOM docs, the truth turns to be disappointed, no function is provided to get this information in JDOM level 2(the current released one), while it's promissed that this function will be provided in JDOM level API....
    Thanx all for your help and attention!!!

  • How to read the attribute in mapping..

    Hi,
    My source XML looks like this
    <GLDEBITACCT>
                <VALUE>0545-K-2006605-5500001</VALUE>
                <GLCOMP glorder="0">0545</GLCOMP>
                <GLCOMP glorder="1">K</GLCOMP>
                <GLCOMP glorder="2">2006605</GLCOMP>
                <GLCOMP glorder="3">5500001</GLCOMP>
      </GLDEBITACCT>
    Where glorder is the attribute of GLCOMP. Now I have requirement to read the attribute ( atleast 2 of them)
    I have to map to target field checking the value in glorder="1
    For e.g. with above XML, if the value in glorder="1 is K than map value from glorder="2 (2006605) to Target 1.
    IF the glorder="1 is P map the value in glorder="2 to Target 2 and goes on for another one
    How can i acheive this mapping. When I tried putting the value of glorder, i am not getting anything.
    Regards,

    Hi,
    You can use below UDF. Please make sure to select context parameter while creating UDF. There will be 3 input arguments for this function:
    1. GLCOMP (a)
    2 @glorder   (b)
    3 Constant   (c)  --depending upon the target node
    Also conext of attribute @glorder should be same as that of GLCOMP.
    //write your code here
    for(int i=0;i<a.length;i++)
        if(b<i>.equals("1")&&c[0].equals(a<i>))
        for(int j=0;j<a.length;j++)
              if(b[j].equals("2"))
         result.addValue(a[j].toString());
                            break;
    For target node target1 use K as 3rd argument, for target node target2 use P and so on.
    Let me know how it works.
    Regards,
    Anirudh.

  • How to read the attribute in another context node from setter method

    Hi,
    As part of the  requirement
    i need to read the STRUCT.E_MAIL ( attribute ) present  in  INDEPENDANTEMAIL context node  from  the SET_S_SRUCT method of the context node  HEADER.
    I tried th following but it didnt work out....
    Get the Custom Controller Path
    *lr_cuco ?= controller->get_custom_controller( controller_id = 'BP_HEAD/IndComm').
    *IF lr_cuco IS BOUND.
    Get the Entity
    *lr_entity ?= lr_cuco->typed_context->independantemail->collection_wrapper->get_current( ).
    *ENDIF.
    *CHECK lr_entity IS BOUND.
    Get the Trade Event Type.
    *lv_email  = lr_entity->get_property_as_string( 'E_MAIL' ).
    also i tried ...
    data:
    *lv_value type string,
    *lr_property type ref to if_bol_bo_property_access.
    *lr_property = collection_wrapper->get_current( ).
    *lv_value = lr_property->GET_PROPERTY_AS_STRING( importing iv_attr_name = 'E_MAIL'
                                                returining  ev_result    = lv_email ).
    but it didnt workout ......
    Any suggestions   ...................
    Regards,
    Sijo...

    Hi,
    Both Context node are available in view then refer this link.
    Reading Attributes from different context nodes in the same view
    Relationship name for context node INDEPENDENTMAIL is 'BuilIndependantEmailRel'
    Regards
    Gaurav

  • How to read the attributes of XML file

    Hi this is ant,
    I am new to java, XML, I have a senario
    1) I have to read all the href attributes for topicref child, and then read the corresponding xml file which is mapped in href="".
    First.xml
    <map>
    <topicref nav="garage" href="task/gar/view.xml" class="..">
    <linktext class="_map/linktext">Garage</linktext>
         <topicref nav="" href="task/gar/change.xml" ..>
    <linktext class="_map/linktext">Garage</linktext>
    </topicref>
    </linktext>
    </topicref>
    </map>
    2) task/gar/view.xml file , has id attribute & need to get the id values.
    Like this I have to get the id values for all the href attributes of first xml & read correspoding id values.
    I have just read some doc using XPATH we can do, please help me.
    Thanks.
    anto

    * Try this Link, there is solution
    http://forums.sun.com/thread.jspa?messageID=9665228
    Can...Can...If we try...!

  • Update Routine - Reading the attribute

    I am using 0PA_C01 cube (3.x flow only). I have a requirement to generate SBU field based on the 0PERS_AREA values. 0PERS_AREA is the attribute of 0EMPLOYEE. The code will be written as update routine.
    I am getting difficulty in how to read 0PERS_AREA. It does not appear in COMM_STRUCTURE as this a attibute of 0EMPLOYEE.
    Do we use any form for it? Please guide.

    Hello,
    You can write a start routine where you read the 0PERS_AREA values from the master data table of 0EMPLOYEE.You can store teh raed values in the start routine into a internal table.
    Then for the  SBU field  in the update rule,write a update rouitne to calculate the same by reading that internal table.
    You can find some sample code in the thraeds:
    /message/5918323#5918323 [original link is broken]
    Re: Look up at master data in  update routine
    Regards,
    Dhanya

  • How to read the attribute of a XML element? Please help!

    Hi experts,
            <Batch>
                  <BatchCode ID= AA>
                    <DeliveryNote>190098</DeliveryNote>
                    <LotQuantity>1560</LotQuantity>
                  </BatchCode>
                  <BatchCode ID= BB>
                    <DeliveryNote>190098</DeliveryNote>
                    <LotQuantity>1560</LotQuantity>
                  </BatchCode>
              </Batch>
            Target message:
                <BatchDelivery>
                  <DeliveryNote>190098</DeliveryNote>
                  <DNQuantity>1560</LotQuantity>
                </BatchDelivery>
           From the source message I want to pull only those batch details where ID is BB.
           How to handle thsi in mapping?
    Thanks
    Gopal

    Hi Prabhu,
             I ma sorry I have two levels of checks in my source XML.
    <Batch>
    <BatchCode ID= AA>
    <BatchLabel>Primary</BatchLabel>
    <DeliveryNote>190098</DeliveryNote>
    <LotQuantity>1560</LotQuantity>
    </BatchCode>
    <BatchCode ID= BB>
    <BatchLabel>Secondary</BatchLabel>
    <DeliveryNote>190098</DeliveryNote>
    <LotQuantity>1560</LotQuantity>
    </BatchCode>
    <BatchCode ID= BB>
    <BatchLabel>Primary</BatchLabel>
    <DeliveryNote>190098</DeliveryNote>
    <LotQuantity>1560</LotQuantity>
    </BatchCode>
    </Batch>
    So I need to pull batch details where first the BatchCode ID= AA and then where BatchLabel value is 'Primary'
    Target message:
    <BatchDelivery>
    <DeliveryNote>190098</DeliveryNote>
    <DNQuantity>1560</LotQuantity>
    </BatchDelivery>
    How to do the graphical mapping for this situation?
    Thanks
    Gopal

  • 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

  • Sychronisation AD - OID: Is it possible to read the user password from AD?

    Hi.
    We are using the Oracle Internet Directory shipped with the Oracle 9i Database Rel. 2 (9.2.0.1).
    I try to synchronise the user accounts from AD to OID using JAVA JNDI. I'm able to read all necessary user information except the user password (MD5 value). Even if I connect to the AD using SSL, it's not possible to read the attribute userPassword.
    Is anybody out there who got this work or knows a way (may also be by the use of another programming language or tool) to get the user password out of AD? Is this possible? How does the Oracle Integration Agents accomplish this?
    Thanks in advance.
    Hermann S.

    Hermann,
    I am working with this as well, though from AS10g, not RDBMS. According to the OID Administrator Guide chapter 43, page 43-52:
    <snip>
    Synchronizing passwords from Microsoft Active Directory to Oracle Internet Directory is not possible in the Oracle Application Server 10g release because passwords in Microsoft Active Directory are not accessible by LDAP clients. However, if a deployment requires passwords to be available in Oracle Internet Directory, then the following two methods are recommended:
    Build a custom plug-in for Microsoft Active Directory that captures a password change and synchronizes it with Oracle Internet Directory
    Manage Active Directory passwords from the Oracle environment. This enables passwords to be available in both Oracle Internet Directory and Microsoft Active Directory because the Active Directory connector can synchronize passwords from Oracle Internet Directory to Microsoft Active Directory.
    </snip>
    As10g can however look up the password in AD using the "Active Directory External Authentication Plug-In". This is documented in the same chapter.
    Hope this helps,
    Jens

  • Is there any way to read the field name,through the property binded to it.

    Hi
    I want to know that,is there any method exits with which i can find the field names of the screen,if i have the property attribute with me.
    as my req is to make the validation for the property attr,& check  how many fields are binded with the single property attr,i have read the property attr dynamically,now need to find the fields linked,& need to check how many fields have not field value,& through the error msg.

    just read the attribute binded to properties using code wizard ( Control + F7).
    Code generalted will be like :
    DATA lo_nd_cn_check TYPE REF TO if_wd_context_node.
        DATA lo_el_cn_check TYPE REF TO if_wd_context_element.
        DATA ls_cn_check TYPE wd_this->element_cn_check.
        DATA lv_ca_check LIKE ls_cn_check-ca_check.
      navigate from <CONTEXT> to <CN_CHECK> via lead selection
        lo_nd_cn_check = wd_context->get_child_node( name = wd_this->wdctx_cn_check ).
      get element via lead selection
        lo_el_cn_check = lo_nd_cn_check->get_element(  ).
      get single attribute
        lo_el_cn_check->get_attribute(
          EXPORTING
            name =  `CA_CHECK`
          IMPORTING
            value = lv_ca_check ).
    Here i have read attribute CA_CHECK.

  • Reading multivalued attribute

    Hi,
    I have a multivalued attribute defined in LDAP and was synchronized to plumtree. After synchroinzation, the attribute with multiple values came in to plumtree and I am able to see the values of the attribute by clicking on user profile. But when I try to read the attribute using the following query only the last value is coming up.
    Here is the query I am using.
    IPortletContext portletContext = PortletContextFactory.createPortletContext(request, response);IPortletRequest portletRequest = portletContext.getRequest(); out.write("locationString = " + portletRequest.getSettingValue(SettingType.UserInfo,"ttcmytlocation"));
    In the profile of the user ttcmytlocation attribute has multiple values, but reading returns only the last value. Is there any other way to query the values? Please help!!
    Thanks.

    Use LDAP is ticked but no server specified
    Tried Selecting the server but no effect
    Every where I look in POA, Domain setting its set to the SERVER's IP address
    not DNS name!!
    Copied NAMED.NLM (just the NLM) from SP5 server - error gone but still get
    the LDAP error 81 when a
    user tries to login to GW.
    I also POA > Security - I tried setting security to LOW (which unticks LDAP)
    but still can't login
    "Anders Gustafsson" <[email protected]> wrote in message
    news:[email protected]..
    > Eric,
    >> "Starting eDirectory integrated Novell DNS Server...
    >> error:NWDSRead Failed while reading a multivalued attribute: -603
    >> Loading the configuration and zone data completed .
    >> DNS Server running "
    >>
    > OK. I assume that you have configured your POA to use the same server for
    > LDAP. If so, did you use the DNS name or IP address? If DNS name, I
    > suggest you try IP address as this takes DNS out of the picture.
    >
    > The error you are seeing indicates that you are not current on servicer
    > packs:
    > http://www.novell.com/support/search...200%2043955231
    >
    > I suggest you apply SP6 plus the post SP6 fixes after resolving your POA
    > issue and reading this:
    > http://wiki.novell.com/index.php/Nw65sp6
    >
    > - Anders Gustafsson, Engineer, CNE6, ASE
    > NSC Volunteer Sysop
    > Pedago, The Aaland Islands (N60 E20)
    >
    > Novell does not monitor these forums officially.
    > Enhancement requests for all Novell products may be made at
    > http://support.novell.com/enhancement
    >
    > Using VA 5.51 build 315 on Windows 2000 build 2600
    >

  • Sample java code which reads xml attributes using DOM Parser

    Hi Friends,
    I am looking for a sample java code which uses the DOM Parser to read the attributes values.
    My xml looks like below
    <?xml version='1.0' encoding='UTF-8'?>
    <root>
    <header unid="100" status="true">
    <validation stage="1" processed="10"/>
    </header>
    </root>
    Experts please help...
    Thanks in Advance
    JJ

    You have probably found lots of resources on the www for this by now, if not: [http://www.w3schools.com/dom/default.asp|http://www.w3schools.com/dom/default.asp]

  • Reading the value of the "WaitForTarget" attribute of the Wait step

    I am trying to access the  "Step.WaitForTarget" attribute for the Wait step but can't find the correct syntax to use in an expression or the correct API calls to use in an action step.  I intend to use this in an expression as I am looking for a specific value.
    I have a object reference to the step that I am testing  (Locals.StepRef) and from that I have no issues reading the standard attributes like name, step type, preconditions, etc...
    How do we access the special additional properties of the wait step ?
    Solved!
    Go to Solution.

    Hey 4watt,
    One easy way to do this is to access the step reference as a PropertyObject and use GetValNumber to obtain the value. For example:
    Locals.StepRef.AsPropertyObject.GetValNumber("WaitForTarget",0)
    I tested this out and it does correctly return the value of WaitForTarget. Let us know if you need any more assistance!
    Daniel E.
    TestStand Product Support Engineer
    National Instruments

  • Unlock a FM file that does not have the Read-only attribute?

    I have FrameMaker 8.0p277. I was trying to import formats from a file on my network. Everything froze. I had to reboot. When I reopened my FM book file and the individual chapter files, I got the lock message that prompted me to reset the lock and open each file. I did that--opened each file and reset the lock in each file. However, when I go to update my files, I get a message that one of my files is read-only. The attribute settings does not say this. I also can't even click in this file any more. I tried removing it from my book file and adding it back in. But that didn't change anything. Is there a way to get this file unlocked again?

    This happened to us once.
    Be sure you are pressing the keys sequentially, except for F, that is:
    Esc
    Shift+F
    l
    c
    Except for Shift+F, do not press all the keys at the same time.

  • [JS-CS4] - How to read the XML Element and its Attributes

    Dear All,
      I have the doubt regarding: reading the xmlElement and its attributes.
    Here I droping the xml script
    //============= Start ======================//
    var myDoc = app.activeDocument;
    var Fpath = File("../Projects/Entity_map.xml");
      if (Fpath.exists)
       Fpath.open("r");
       var Cont= Fpath.read();
      var roots = new XML(Cont);
      var myEveryName = new Array();
      var myEveryContent = new Array();
      var myEveryAttributes = new Array();
      traverse(roots);
    //$.writeln(myEveryName);
    //$.writeln(myEveryContent);
    $.writeln(myEveryAttributes.length);
    for(var i=0; i<myEveryAttributes.length; i++)
      $.writeln(myEveryAttributes[i]);
    function traverse(tree) {
        myEveryName.push(tree.name());
    myEveryContent.push(tree.text());
      myEveryAttributes.push(tree.getAttribute);
    // you get the contents by using .text() insted of .name()
        if(tree.elements().length() > 0) {
            for(var i=0; i<tree.elements().length(); i++) {
                traverse(tree.elements()[i]);
    //============== End =====================//
    and the XML Structure is
    //===============XML =====================//
    <?xml version="1.0" encoding="UTF-8"?>< Entity_Convertion>
    < Entitys char="Ç" GID="173"/></ 
    Entity_Convertion>
    //===============End ====================//
    Here I'm getting the XML Elements and its contents, but not xmlAttributes.
    Please any one can help me, then I will appreciate...
    Thanks & Regards
    T.R.Harihara SudhaN

    Dear All,
      I have the doubt regarding: reading the xmlElement and its attributes.
    Here I droping the xml script
    //============= Start ======================//
    var myDoc = app.activeDocument;
    var Fpath = File("../Projects/Entity_map.xml");
      if (Fpath.exists)
       Fpath.open("r");
       var Cont= Fpath.read();
      var roots = new XML(Cont);
      var myEveryName = new Array();
      var myEveryContent = new Array();
      var myEveryAttributes = new Array();
      traverse(roots);
    //$.writeln(myEveryName);
    //$.writeln(myEveryContent);
    $.writeln(myEveryAttributes.length);
    for(var i=0; i<myEveryAttributes.length; i++)
      $.writeln(myEveryAttributes[i]);
    function traverse(tree) {
        myEveryName.push(tree.name());
    myEveryContent.push(tree.text());
      myEveryAttributes.push(tree.getAttribute);
    // you get the contents by using .text() insted of .name()
        if(tree.elements().length() > 0) {
            for(var i=0; i<tree.elements().length(); i++) {
                traverse(tree.elements()[i]);
    //============== End =====================//
    and the XML Structure is
    //===============XML =====================//
    <?xml version="1.0" encoding="UTF-8"?>< Entity_Convertion>
    < Entitys char="Ç" GID="173"/></ 
    Entity_Convertion>
    //===============End ====================//
    Here I'm getting the XML Elements and its contents, but not xmlAttributes.
    Please any one can help me, then I will appreciate...
    Thanks & Regards
    T.R.Harihara SudhaN

Maybe you are looking for

  • How do I convert a PDF file to Power Point?

    How do I convert a PDF file to Power Point?

  • 5g 30gig iPod not working after update, Please Help!

    I have a 5th gen 30gig iPod and a yesterday I tried to update it. During the update after it shut itself off and started back up the updater froze around 20%. After about two hours of waiting I forced the updater to quit (restarted it with menu/selec

  • 64bit version again

    Hey! What about building a pure 64bit version for Linux?? I bet 90% ov Linux users use 64bit system, so why should we mess our systems with redundant 32bit libs? Having trouble building it? Having too little time for that? In the Linux world there is

  • Youtube video playback is jumpy.

    Youtube was working fine for me a few days ago. Now, when I play videos they are jumpy and shaky. The audio is fine. I have already tried a software update, flash update, and rebooting. What can I do to fix it?

  • Image in VC.

    Hi Experts, I am new to VC. I need to get data from R/3 in RFC which is sending data in table in the VC project i need to extract the data from table and for every data i have to display corresponding Image at the portal end along with the data. I ne