Xpath: get attributes from first child node

Hi,
I have some problems by getting the attributes from the first child node, if i try to get child elements everything works fine, but whenever i need the elementvalue from a node with attributes i doesn't return anything.
The xpath expression works fine if i want to get the element value from all childs, but not when i just want from one of them.
This one works,
XPathFactory factory1 = XPathFactory.newInstance();
    XPath xpath = factory1.newXPath();
    xpath.setNamespaceContext(new PersonalNamespaceContext());
    XPathExpression expr
     = xpath.compile("//default:DeviceExchange[1]/default:Status/text()");
   // gets the value of the node picked out
    Object result = expr.evaluate(doc, XPathConstants.NODESET);
    NodeList nodes = (NodeList) result;
    for (int i = 0; i < nodes.getLength(); i++) {
      names[i] = nodes.item(i).getNodeValue();
      String a = names;
// checks if status is exchanged, if it is sets status to 1
if (a.length() == 9){
names[i] = "1"; }
else{  names[i] = "0";}
System.out.println(names[i]);This doesn'tXPathFactory factory2 = XPathFactory.newInstance();
XPath xpath2 = factory2.newXPath();
xpath2.setNamespaceContext(new PersonalNamespaceContext());
XPathExpression expr2 = xpath2.compile("//default:DeviceExchange[1]/default:Field[@names='MLPKTID']/text()");
Object result2 = expr2.evaluate(doc, XPathConstants.NODESET);
NodeList nodes2 = (NodeList) result2;
for (int i = 0; i < nodes2.getLength(); i++) {
names2[i] = nodes2.item(i).getNodeValue();
System.out.println(names2[i]);}Does anyone have any ideas? I will apreciate all help!
Edited by: fusen on Oct 25, 2007 1:12 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Sorry, solved myself. Just � typo that that i couldn't detect.

Similar Messages

  • Cannot get attributes from different child elements...

    Hi,
    I have an Xpath expression which happily gives me all the 'element' elements when I put in the the step variable(1, 2 or 3), see below....
    "/remove[@step < "+step+"]/element"
    <remove step="1">
         <element path="epg.schedule.programme.longName" />
         <element path="epg.schedule.scope" />
    </remove>
    <remove step="2">
         <element path="epg.schedule.programme.mediaDescription" />
    </remove>
    <remove step="3">
         <element path="epg.schedule.programme.genre" />
         <element path="epg.schedule.programme.memberOf" />
         <element path="epg.schedule.programme" />
    </remove>
    But when I ask for each elements attribute 'path' it only every returns the paths for step 1...
    "/remove[@step="+step+"]/element/@path"
    Any ideas greatly appreciated.
    Thanks.
    Paul.

    If the xpath expression
    "/remove[@step["+step+"]/element/@path"is selected with a selectSingleNode method the first <element/> in the <remove/> element gets selected.
    If the xpath expression is selected with with selectNodes method a node list of elements is returned.
    To select an element specify the xpath expression:
    "/remove[@step[3]/element[1]/@path"seelcts the path attribute for the first element in the third remove element

  • How to use attributes from different context nodes in one view?

    I am VERY new to the concept of CRM and currently working on creating an alternate version of the BP_HEAD_SEARCH. With help from SAPPRESSs book 'SAP CRM Web Client' i was ble to create my own simple Z-component.
    However after going back and forth the book and the forum (including this [article|https://wiki.sdn.sap.com/wiki/display/CRM/Howtoaddanexistingfieldtoasearchpageofadifferent+component]) i was not able to find a solution to my problem. My current search uses BuilHeaderAdvancedSearch as context node for searching. But the search should also be able to use attributes from BuilActivity, which is directly related to BuilHeader. I can't seem to find a way to get attributes from BuilActivity into the search window of my component without having to change SAP-Standard.
    Is this really the only way? Please advise on possible code and insertion point.

    Any suggestions?

  • Issue on deployment: Solution Deployment : Missing one or more of the following attributes from the root node in solution .wsp: assembly '', type ''

    Hi,
    I have the following issue when deploying:
    Solution Deployment : Missing one or more of the following attributes from the root node in solution .wsp: assembly '', type ''
    The solution is a farm solution (was never sandbox) and it deploys fine.
    It was updated several times with success. We did not see this issue until recently when we had some other issue (unrelated) and looked at the logs. The solution is updated without problem and updates are available for the user. But we can see this error
    in the logs at the update time. 
    Any idea what might cause this?
    Pop Anisia

    Hi,
    This error is wide meaning, as it can come from differences between SP versions, variables types used, bad manifest file, WebConfiguration ...
    You can try to redeploy the solution.
    retracted the solution,removed all the previous ref, removed dll from GAC and folder from 14\features and reset the iis, deploying it again.
    Here are some similar issue post, you can use as a reference:
    https://social.technet.microsoft.com/Forums/office/en-US/72ac9a02-3a51-48b8-9e36-3b24a2d4da74/missing-one-or-more-of-the-following-attributes-from-the-root-node-in-solution-alertbdcwsp?forum=sharepointgeneralprevious
    https://social.technet.microsoft.com/Forums/office/en-US/331af288-5ba6-48a7-9e9d-ac4e4bc8f8fa/missing-one-or-more-of-the-following-attributes-from-the-root-node-in-solution-xxxwsp-assembly-?forum=sharepointdevelopmentprevious
    In additional, you can check the ULS log (C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\LOGS) to get the detailed information.
    I hope this helpful.
    Best Regards,
    Lisa Chen
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Reading Attributes from same context node of different attributes

    Hi,
    I  want read Attributes from same context nodes of diifrent attributes.
    I have attribute A and B of same node, want to get read value from  atrribute A into B.
    Regards,
    Brahmaji

    solved
    DATA: lv_current TYPE REF TO if_bol_bo_property_access.
       DATA: lv_value type String.
       IF iterator IS BOUND.
        lv_current = iterator->get_current( ).
      ELSE.
        lv_current = collection_wrapper->get_current( ).
      ENDIF.
      CALL METHOD current->get_property_as_string
            EXPORTING
              iv_attr_name = 'ZZAFLD00004Y'
            RECEIVING
              rv_result    = lv_value .

  • Querying for first child node's value of a certain tag

    Hi,
    I am using the java parser 2 from Oracle. Given a XML document
    containing the following
    <course>
    <Name>Calculus</Name>
    <Dept>Math</Dept>
    <Instructor>
    <Name>Jim Green</Name>
    </Instructor>
    <Student>
    <Name>Jack</Name>
    <Name>Mary</Name>
    <Name>Paul</Name>
    </Student>
    </course>
    I want to efficiently obtain the value of first child node of
    <course> whose tag is <Name>.
    I could not find any mtd that can do that efficiently. The
    nearest match is the mtd getElementsByTag("Name") which
    traverses the entire tree under <course>.
    Any help appreciated !
    Thanks in advance
    Mak
    null

    Mak (guest) wrote:
    : Hi,
    : I am using the java parser 2 from Oracle. Given a XML document
    : containing the following
    : <course>
    : <Name>Calculus</Name>
    : <Dept>Math</Dept>
    : <Instructor>
    : <Name>Jim Green</Name>
    : </Instructor>
    : <Student>
    : <Name>Jack</Name>
    : <Name>Mary</Name>
    : <Name>Paul</Name>
    : </Student>
    : </course>
    : I want to efficiently obtain the value of first child node of
    : <course> whose tag is <Name>.
    : I could not find any mtd that can do that efficiently. The
    : nearest match is the mtd getElementsByTag("Name") which
    : traverses the entire tree under <course>.
    : Any help appreciated !
    : Thanks in advance
    : Mak
    Your best bet, if you do not need the entire tree, is to use the
    SAX interface to return the desired data. Since it is event
    driven it does not have to parser the while document.
    Oracle XML Team
    http://technet.oracle.com
    Oracle Technology Network
    null

  • Reading Attributes from different context nodes in the same view

    Hi,
    I have added a new field as part of an enhancement for Trade Promotions. This field is a checkbox and part of the context node TRADE in the view TPMOE/HeaderEOF. This field will be checked or unchecked using a logic in the background.
    The logic will be based on an attribute (Fund Plan ID) which is part of another context node FUNDPLAN in the same view.
    How can I read the attribute of FUNDPLAN context node in TRADE context node?
    A sample code will be quite helpful as I am new to CRM 2007.
    Thanks,
    Abhishek
    Edited by: Abhishek  Periwal on Oct 16, 2008 2:35 PM

    Hi Abhishek,
    If I understand your question correctly, you would like to access the Fund plan ID (in a different context node) in the getter setter methods of the check box attribute which you have added.
    The code snippet mentioend by sudeep works perfectly fine when you are making any checks in the view implementation class. But since you are in the getter setter methods of the context class, this doesnot work as "me" always refers to the class instance in which you are present.
    Now in this case what you need to do is :
    1)  create an attribute <view_controller> in your context class. Here the context is TRADE. The type of this attribute wud be same as the view controller class CL_TPMOE_HEADEREOF0_IMPL
    2) Go to the view controller class and redefine the method
    DO_VIEW_INIT_ON_ACTIVATION. This method is called only once when the view is loaded for the first time.
    3) In this method, put the following code
    me->typed_context->(Trade)->[view_controller] = me.
    by the above code, you are setting the newly created attribute to the view controller instance.
    4) The next step would be, go back to your getter setter methods or what ever it may be, try referring to the Fund plan ID by the code snippet mentioned below
    data: lr_entity type ref to cl_crm_bol_entity.
    lr_entity ?= me->[view_controller]->typed_context->[the context node in which the fund plan id is present]->get_current().
    lv_field_value = lr_entity->get_property_as_String( **pass the field name here ).
    This should definitely resolve the problem.
    Thanks,
    Vinay

  • Getting list of possible child nodes

    I'm trying to find an automated way to get a list of all the possible child nodes for a given element based on a schema. How does one go about doing that in Java? The closest match I could find was the class ElementEditAS, but it's deprecated with no mentioned replacement or alternative.
    Any help would be greatly appreciated.

    You are right, but what may seem simple is not.
    1) You can have combinations of choice and sequence constructs in the contents.
    2) The element definitions are just references to true definitions somewhere else.
    3) You can include other schema files, so you need to work with an arbitrary number of files at the same time.
    Basically, all you have to do is read one or more schema files as XML files, probably using DOM or JDOM or whatever you know. Avoid SAX, since you need the full tree structure of the schema file.
    Having done something similar, be aware that element names are described in attributes of the element tag, and attributes are defined as elements. Be ready to redo your code a time or two because the names you use (attribute and element) are not working as you expected.
    Dave Patterson

  • Getting attributes from a XML File, stored in Oracle

    Hello,
    my problem is the following
    I have a xml file that looks like that:
    <?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
    <root path="H:\musik">
    <directory name="Bj�rk - Homogenic" path="H:\musik\Bj�rk - Homogenic">
    <file album="Homogenic" artist="Bjoerk" comment=""
    completename="Bjoerk - Hunter" genre="Techno"
    name="01 - Hunter.mp3"
    path="H:\musik\Bj�rk - Homogenic\01 - Hunter.mp3"
    title="Hunter" year="1997"/>
    <file album="Homogenic" artist="Bjoerk" comment=""
    completename="Bjoerk - Joga" genre="" name="02 - Joga.mp3"
    path="H:\musik\Bj�rk - Homogenic\02 - Joga.mp3" title="Joga" year="1994"/>
    </directory>
    <directory name="Blank & Jones - In Da Mix" path="H:\musik\Blank & Jones - In Da Mix">
    <file album="In da Mix" artist="Blank & Jones" comment=""
    completename="Blank & Jones - On a journey (Intro)"
    genre="Dance" name="01 - On a journey (Intro).mp3"
    path="H:\musik\Blank & Jones - In Da Mix\01 - On a journey (Intro).mp3"
    title="On a journey (Intro)" year="1999"/>
    <file album="In da Mix" artist="Blank & Jones" comment=""
    completename="Blank & Jones - Cream" genre="Dance"
    name="02 - Cream.mp3"
    path="H:\musik\Blank & Jones - In Da Mix\02 - Cream.mp3"
    title="Cream" year="1999"/>
    </directory>
    </root>
    This file I have stored in Oracle as table of XML Type.
    Now I have build a little Java Programm, that displays the XML File like the File structure in the Windows Explorer.
    I want, when I choose a file in the File structure, that the ID3 Informations like album artist a.s.o. can be displayed. My problem is, I couldn't get these informations e.g. in an array from the database. Any suggestions how I could realize this in Java?
    Thx for any comments
    Max

    Try this:
    select extract(xmltypefieldname, '//xpath/field@attribute').getStringVal() from yourtable where yourwhereclause
    You can also select elements that match certain attributes by using a predicate such as field[@attr = myval][@attr2 = myval2]...
    Hope this helps.

  • Values not getting displayed from first page of the report.

    Values in the report is getting displayed from second page.
    First page in the report only displaying the report title and column names.
    Secone page onwards, data and column names are generated.
    Can any one please help me, with the cause of the problem.

    what reporting tool?
    Interactive Reporting
    Financial Reporting

  • Check the value of attribute of a child node in datatype xmltype.

    Hello,
    I have a xml stored in column having datatype as "XMLTYPE"
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <Settings>
      <Setting Name="A1" Value="N"/>
      <Setting Name="A2" Value="N"/>
      <Setting Name="A3" Value="SOMEVALUE"/>
      <Setting Name="A4" Value="N"/>
      <Setting Name="A5" Value="Y"/>
      <Setting Name="A6" Value="N"/>
    </Settings>I do not want to loop into each child node. But want to find out if the value of setting A5 is Y or N? Is there a way I can find that without doing the extract of "Setting" child node and then looping each node to find the value?
    Regards,

    You didn't specify your version of Oracle so here are two options. If 10.2 or greater, use XMLTable, else use the ExtractValue option.
    -- The WITH simply simulates your existing table that I do not have.
    WITH fake_tab AS
    (SELECT XMLTYPE('<?xml version="1.0" encoding="ISO-8859-1"?>
    <Settings>
      <Setting Name="A1" Value="N"/>
      <Setting Name="A2" Value="N"/>
      <Setting Name="A3" Value="SOMEVALUE"/>
      <Setting Name="A4" Value="N"/>
      <Setting Name="A5" Value="Y"/>
      <Setting Name="A6" Value="N"/>
    </Settings>
    ') tab_col
      FROM dual)
    -- For 10.2 and higher use this SELECT
    SELECT a5
      FROM fake_tab,
           XMLTABLE('/Settings'
                    PASSING fake_tab.tab_col
                    COLUMNS
                    a5   VARCHAR2(10)  PATH 'Setting[@Name="A5"]/@Value');
    -- For 10.1 and before
    SELECT ExtractValue(tab_col, '/Settings/Setting[@Name="A5"]/@Value')
      FROM fake_tab;

  • How to get value from one context node to otehr contect conde in diff views

    Hello Guru's
    We have a rek which is of getting the value from one context node to other context node,
    for example there is Total value in BT111H_OPPT/ITEMLIST (One context node) we need to have the same Total value in the in BT111H_OPPT/DETAILS (other context node) automatically
    Inputs are highly appricated.......

    Hello,
    Thanks for your Reply
    But my rek is i want to get value from different views
    eg BT111H_oppt/itemslist(contex node - BTADMINI) field net value to BT111h_opp/Details(Context node - BTopporth)
    for this which method should i use to chive this.
    Thanks..

  • Executing jscript from tree child node

    Hi,
    I am trying to execute a jscript code when pressing tree child node (commandLink)
    to launch a popup, but in vain.But I succeed to launch the popup from another side.
    I used
    <af:commandLink text="#{node}">
    <af:showPopupBehavior popupId="MyPop"/>
    <af:clientListener method="showPopup" type="action"/>
    </af:commandLink>

    I am confused by the code sample. You have a clientListener to launch the popup and you use the showPopupBehavior component. Either case amounts to roughly the same code so you are calling the popup twice.
    --Ric                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Getting Attributes from an org unit

    Hi
    How can I get attributes and their values given an organization unit?? ie org id?
    Is there any function module or any tables which contain the required data?Plz help out.
    Thanks.

    Hi
    Thanks for the details.
    Your workflow configuration is quite strange.
    <u>Couple of questions to ask here :-></u>
    <b>1) what's your business requirement ?
    2) which SRM version are you using ?
    3) which SRM scenario have you implemented ? (Classic/Extended Classic/Standalone)
    4) What do yo mean by "I am thinking of creating a org structure with each row of criteria as one position say manager1, manager2 etc.". Are you talking about Workflow Configuration using PPOMA_BBP Transaction ? Are you looking for Functional aspect or you need to implement by coding (Technical Aspect) ?
    5) I remember you told in your earlier reply that you are looking for Technical aspect by creating a function module inside N-Level Approver BADI (BBP_WFL_APPROV_BADI in SE18). Have you completed that part ? 
    6) Can you maintain a custom table (Z table) and maintain the conditions there and based on the Shopping cart
    values, we can manipulate the list of approvers decided.
    7) What about functional part ? Are you taking care of both Functional and technical aspects of the Workflow configuartion in this case ?</b>
    Please send me the detailed information.
    Hope this will help.
    Regards
    - Atul

  • XPath: get element from node with namespace?

    I have a problem retrieving an element value via XPath. The XML is like
    <?xml version="1.0"  encoding="UTF-8"?>
    <SOAP:Envelope ...>
        <SOAP:Header>
        </SOAP:Header>
        <SOAP:Body>
            <A xmlns="myns/">
                <B>
                    <C>
                        <D>123</D>
    ...I want to retrieve node 'D'. I was able to select node 'A' with this XPath:
    //SOAP:Body/child::*[namespace-uri()='myns']but can't get further. E.g.
    //SOAP:Body/child::*[namespace-uri()='myns']/Bdoesn't work ...?

    I have a problem retrieving an element value via
    XPath. The XML is like
    <?xml version="1.0"  encoding="UTF-8"?>
    <SOAP:Envelope ...>
    <SOAP:Header>
    </SOAP:Header>
    <SOAP:Body>
    <A xmlns="myns/">
    <B>
    <C>
    <D>123</D>
    ode]
    I want to retrieve node 'D'. I was able to select
    node 'A' with this XPath://SOAP:Body/child::*[namespace-uri()='myns']
    but can't get further. E.g.
    //SOAP:Body/child::*[namespace-uri()='myns']/Bdoesn't work ...?
    Is there any solution to this problem?

Maybe you are looking for

  • How mobile device ( rfid/barcode reader) communicates with SAP transaction.

    Dear Friends ! Good morning, How are you ? I want to understand that in ITSmobile How Mobile device ( RFID Reader ot Barcode scanner/reader) to fetch the data and supply the ITS screen. I believe every mobile device has some .dll file or something in

  • Cannot print fill form areas in adobe pro (xp)??

    Hello All I have nevebeen able to take a form, insert a a form field, and get the dang thing to print. I go to button properties, insert my text and choose "hidden but prntable" ........but I still get a grey box with no text field when I print. I kn

  • Is the Iphone 5 model A1429 (CDMA) and model A1429 (GSM) the same phone?

    Apple is inconsistent on their information for the iphone 5. One the LTE info site (http://www.apple.com/iphone/LTE/) it lists three different models, specifically showing that there is both a GSM and CDMA version of Model A1429. However, on the ipho

  • 24" As HD monitor?

    Is it possible to use the 24" iMac as a HD monitor for a Xbox 360? and if so what would I need to do that? Would I have to get an EyeTV device?

  • Adobe Aftereffects crashing at random intervals

    Hi, My colleuges Adobe CS4 Aftereffects is crashing at random intervals while using the program. I need to end multiple instances of aftereffect.exe and also the cs4 application before I can reload the program and carry on working with it. Any sugges