XPath text() node comparison

I have an XML document that looks something like:
<A>
<B>One
</B>
<B>Two
</B>
<B>Three
</B>
</A>
I am using XPathAPI to evaluate my XPath Expressions and I would like to write an expression that will select a node of type B based on the value of its text node. I looked around for some examples at how to compare a text node but I couldn't find any. I thought it would be something like "//B[@text()='Two']" (or something similar) but nothing I have tried has worked. Can anyone offer some advice?
Thanks in advance,
Matt

I think you're close. But the "@" in your expression is shorthand for the attribute axis, for example "@text" would be looking for an attribute named text. Try this instead:
//B[text()='Two']
Also beware of whitespace; your example has a B element whose text node contains 'Two' followed by a newline character, and the example above won't match that. To get rid of surplus whitespace, use the normalize-space function (I think that's it, check your reference):
//B[normalize-space(text())='Two']

Similar Messages

  • XMLSearch / case in-sensitive search in a text node value with XPATH

    Hi everyone,
    I was aggregating some XML files and queries for a search
    engine. It is pretty easy with coldfusion XML functions BUT ....
    I was looking around XMLSearch to do a simple text search
    into nodes and I am stuck with it.
    with something like that :
    selectedElements = XmlSearch(myxmldoc,
    '(/directory/user[contains(.,"#form.firstName#")])');
    Without loop all the XML elements, I cannot put firstName
    text nodes to lower-case, do a simple search into the directory and
    get user entries.
    Is it possible to do with XPATH something like that :
    selectedElements = XmlSearch(myxmldoc,
    '(/directory/user[contains(lower-case(.),lower-case("#form.firstName#"))])');
    Thanks for your help.

    When Do you think coldfusion will implement Xpath functions
    as
    http://www.w3schools.com/xpath/xpath_functions.asp
    ????

  • In SMARTFORMS when openee a Text Node,   Giving a Short Dump

    Hi
    I am getting Short Dump in SMARTFORMS Transaction, when ever I opened a Text Node and made some changes in it.
    With out opening a Text Node I can able to change and activate the SmartForm.
    But if I open a Text Node I can able to make changes in the Text Node but later if i click on any other Node, it is giving a Short Dump.
    But all other systems in my office are working fine.
    I have tried the Utilities->Settings-> and changed the editor also. 
    I have also Installed the SAPGUI once again for this Issue. But still I am getting the same problem.
    Can anyone Please help me on this Issue.
    I am sending the error enalysis of the Short Dump.
    Error analysis
        Short text of error message:
        Control Framework : Error processing control
        Long text of error message:
         Diagnosis
             An error occurred when the system tried to process the commands
             from the Automation Queue on the presentation server.
             There are several possible reasons for this:
             - The installation of the SAP GUI on the presentation server is
             faulty or obsolete.
             - There is an error in the application program
             - There is an error in the SAPGUI or an integrated control
         Procedure
             1. Make sure that you have imported the appropriate Support
             Package, the current kernel, and GUI patch for the release of your
             system
             2. Check whether the error occurs locally on one or a few PCs, or
             generally on all PCs. Note whether the error only occurs for some
             users, for example because of a specific Customizing setting.
             If it only occurs locally, this suggests an installation problem
             with the PC. Check the installation; if necessary, reinstall the
             software. In the dump, search for the SY-MSGLI field, since it may
             point to the cause of the error.
             3. Activate the Automation Trace (in accordance with SAP Note
             158985).
             4.Start the transaction and continue until the screen immediately
             before the dump.
             5. From the System -> Utilities menu, choose Autom. Queue,
             Synchronous Processing.
             The status bar of the GUI displays the text:
                "Automation synchron flush mode on"
             6. If you now proceed with the application, the short dump will
             display the ABAP call that caused the error; the Automation Trace
             will contain the error on the presentation server.
             7. If necessary, load the short dump and trace files on to
             sapservX, so that SAP can analyze them.
        Technical information about the message:
        Message class....... "CNDP"
        Number.............. 006
    Thanks in Advance.

    Hi
    I think dump is because of SAP GUI. If you are ECC 6.0 then install SAP GUI 710 with patch level  2 or more and check
    Regards
    Shiva

  • Text node in the Charac Hierarchy sums up

    Hi,
    I am working on IP.
    I had created an hierarchy for a specific consumption data with the top node as a text node, which should appear only once in the report.
    But when i use the Input ready query, the system shows multiple rows of the text node for every new characteristic values in the nodes below this node.
    How do i avoid the text node being displayed multiple times?
    Thanks in advance,
    regards,
    Sriram

    Hi Jacky,
    Yes i have text nodes for more than one set of characteristics.
    Level 1A
        Level 2
            Char1 A
            Char1 B
    Level 1B
            Char1 C
            Char1 D
            Char1 E
    These characteristic also have an attribute characteristic. Hence, in the Input ready query it displays as follows;
    Level 1A
        Level 2          Char2 A
        Level 2          Char2 B
            Char1 A    Char2 A
            Char1 B    Char2 B
    Is there a way to avoid the "Char2" in the text nodes.
    Thank in advance for the solution,
    regards,
    Sriram

  • Text node not showing first line?

    I'm trying to figure out some unexpected behavior with the layout of Text. If I create an example program based on the API documentation
    http://java.sun.com/javafx/1.2/docs/api/javafx.scene.text/javafx.scene.text.Text.html
    Like so:
    Stage
        title: "Application title"
        width: 500
        height: 500
        scene: Scene
            content: [ Text {font: Font { size: 20 } content: "First row\nSecond row" }  ]
    }The resulting screen only shows "Second row", the first line is moved out of the screen above. I need to set y to 20 to show the first line.
    Is that normal?

    Right, Text nodes have an textOrigin, which is default set to the base line. That means that y=0 is just below the letters.
    But the behavior is unexpected when simply adding a Text node and nothing is visible.

  • The text which is in text node is not displaying in output in smartforms

    Hi,
      In smartforms i created a text node and entered some text like following.
         Target Quantity               60000001     60000002          
         Scheduled Quantity               60000003     60000004               
         So far delivered Quantity          60000005     60000006
         Last delivered Quantity          60000007     60000008
          Delivery Schedule Details
    the text which i entered as above in the text node is not displaying.It is in main area.

    Hi
    if u are using table or template inside the main window
    then just mention the position of the text element
    goto text element - output options- output structure tab----give line and column no.
    Thanks
    krushna

  • Account dimension hierarchy text nodes ACCTYPE property

    Hello,
    We have master data being populated into BPC from BW. So for the Account dimension in BPC, we use the 0GL_ACCOUNT infoobject in BW. This infoobject also has all the Financial statement version hierarchies which are being loaded to BPC. The question that I have is, how should the hierarchy text node values for ACCTYPE property be populated if I have to automate this load on a daily basis.
    For the actual GL accounts, we have the account number ranges defined. Like 1* series accounts are Assets etc..So we can easily define a rule for populating the ACCTYPE  property values. But not sure if there is any easy logic for populating the hierarchy text nodes as we dont have any pattern in them. Would we need to maintain it manually always?
    Thanks
    Gaurav

    Hello Richard,
    If there is really no logic behind them there is off course no way of automating this. Then I guess you will have to maintain each node separately.
    Some customers are also willing to change their text node structure. For example I had one when where the rules for the 0HIER_NODE records were as follows:
    *           EXP -> Starts with 32*, 311*, 312*, 321*, 3111*, 3112*,
    *                  3142*,  31111*,  31112*,  311111*
    *           INC -> Starts with TOT, 3000000000, 3100000000, 313*,
    *                  322*, 3113*, 3141*, 31113*, 311112*
    *           AST -> Starts with 1*
    *           LEQ -> Starts with 2*
    Kind regards,
    Christophe

  • How to import hierarchy text node from BW infoobject

    I tried to import hierarchy from BW InfoObject through process chain /CPMB/IMPORT_IOBJ_HIER.
    But BPC complains the hierarchy text node haven't been dimension member.
    As result, I have to export the hierarchy text node to a flat file and import again which is not convenient.
    Does anyone have some best practice for this?
    Thank you.

    Hi,
    You can follow the steps mentioned in the below How-to-Guide of sdn. This explains the steps to be implemeted to inport hierarchies.
    http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/c02d0b47-3e54-2d10-0eb7-d722b633b72e
    Hope this helps.
    Rgds,
    Poonam

  • Carriage Return in Text Node of SmartForm

    Hello SAPients.
    I'm working with a Text node in a SmartForm. I'm using "Include Text" to call an existing text. The text loads fine except that it doesn't respects the CR's.
    What can I do?

    Hello SAPients!
    I'm still having this problem, maybe I didn't explain the problem very well and that's why I didn't get an answer. I hope this information be more helpful:
    I'm working in SAP 4.6C. I have a SmartForm with a Text Node that shows "unlimited" text. I created another transaction to maintain this text in a small text editor and save the text using FM SAVE_TEXT and retrieve it using FM READ_TEXT and it shows everything correct.
    In the SmartForm I'm taking advantage of the option "Include text" in the Text type of the General Attributes of the text node. The system retrieves the text in a normal way, except that the text is shown without Carriage Return, that is, all the text is show in one single line. Do you know why?
    Thank you in advance for your help.

  • How to include std text(Created in So10) in text node?

    Hello,
    How to include the Standard Text( created in So10 ) into Text Node.
    I had typed the Standard text name in the TEXT NAME : ZXXX
          Text Object : TEXT
           TEXT ID : ST
          LAnguage : &CONTROL_PARAMETERS-LANGU&
    But, I am unable to look at that particular text in the smart form. I am receiving an error message : "UNable to load the data into front end. ....etc"
    It is taking me away to the initial screen.
    PLz help!
    ANy suggestion will be appreciated.
    REgards,
    Kittu

    I need to include the Standard text created in so10 into a text node in the Smart form.
    In samrt form, I had created a Text Node.
    In General attributes from the Drop Down menu
    --> I had selected INClude Text
    --> It has asked me TExt name : ZXXX (Name of the STD text create din so10)
                         Text Obje : TExt
                         Text ID   : ST
                         Language  : &CONtrol_Parameters-LANGU&
               It is even activated without any errors. But, it does not display the Text written in the Standard Text. Is there any way that I can include the Standard text into the  Text node.......
    ANy suggestions will be appreciated...
    REgards,
    Kittu

  • Adding text to a text node

    hi
    apologies for the simple question
    ive been searching endlessly for how to add text to a text node
    so far I have
    text body = doc.createTextNode("mynodename");
    previous_element.appendChild(body);
    but what mthod do i use to put in the string beween ie
    <mynodename>how do i put a string in here</mynodename>
    thanks

    elem = doc.createElement("mynodename");
    elem.appendChild(doc.createTextNode("how do i put a string in here"));
    doc.appendChild(elem);

  • XML parser fails to convert html encoded text nodes

    Under the strain of large documents this defect rears its ugly head more often. While parsing a text node containing html encoded chars i.e. < > &; etc...
    The parser will seemingly forget to change the chars at random, 99.9% of the time everything is ok and the proper conversions take place:
    < -> &#60;
    > -> >
    &; -> &#38;
    Once an error occurs it is reproducible until the text node is changed ( values and/or order ) then it is a crapshoot again.
    These tests were done using the default UTF-8 encoding, here is the exception thrown by the parser along with a portion of the text node before and after the first parsing.
    Let me be clear, the parser actually succeeds the first time but the transformation of the HTML encoded pieces possibly fails. It is on the parsing of the text node value as its own document that the parser fails.
    Error 0 : Error parsing XML string! Line :: 1, Column :: 65674
    Error 1 : End tag does not match start tag 'Project'.
    End tag does not match start tag 'Project'.
    at oracle/xml/parser/v2/XMLError.flushErrors (XMLError.java:233)
    at oracle/xml/parser/v2/NonValidatingParser.parseDocument (NonValidatingParser.java:248)
    at oracle/xml/parser/v2/XMLParser.parse (XMLParser.java:117)
    at pacificedge/xml/XMLUtilities.loadParserFromString (XMLUtilities.java:104)
    Preprocessing ::
    <Project stuff0="0" stuff1="0" stuff2="0" stuff3="1" stuff4="100167" stuff5="100213">
    <StuffA>100213</StuffA>
    <Name>I am a Name</Name>
    <StartDate>1998-08-10</StartDate>
    <FinishDate>2000-06-30</FinishDate>
    <Path>Folder1\Folder2</Path>
    </Project>
    Post processing:
    <Project stuff0="0" stuff1="0" stuff2="0" stuff3="1" stuff4="100167" stuff5="100213">
    <StuffA>100213</StuffA>
    <Name>I am a Name</Name>
    <StartDate>1998-08-10</StartDate> <-- Error is raised here when the value of the text node is used as an xml document
    <FinishDate>2000-06-30</FinishDate>
    <Path>Folder1\Folder2</Path>
    </Project>
    Please investigate this. It is a chronic problem for us and possibly many others.
    null

    Sorry for the encoding issues in the message before here are the pertinent pieces hope this shows up correctly.
    &;lt; -> &;#60;
    &;gt; -> >
    &;amp; -> &;#38;
    Preprocessing ::
    &;lt;Project stuff0="0" stuff1="0" stuff2="0" stuff3="1" stuff4="100167" stuff5="100213"&;gt;
    &;lt;StuffA&;gt;100213&;lt;/StuffA&;gt;
    &;lt;Name&;gt;I am a Name&;lt;/Name&;gt;
    &;lt;StartDate&;gt;1998-08-10&;lt;/StartDate&;gt;
    &;lt;FinishDate&;gt;2000-06-30&;lt;/FinishDate&;gt;
    &;lt;Path&;gt;Folder1\Folder2&;lt;/Path&;gt;
    &;lt;/Project&;gt;
    Post processing:
    <Project stuff0="0" stuff1="0" stuff2="0" stuff3="1" stuff4="100167" stuff5="100213">
    <StuffA>100213</StuffA>
    <Name>I am a Name</Name>
    &;lt;StartDate>1998-08-10</StartDate> <-- Error is raised here when the value of the text node is used as an xml document
    <FinishDate>2000-06-30</FinishDate>
    <Path>Folder1\Folder2</Path>
    </Project>
    null

  • #text nodes

    Hello,
    I am parsing xml document using xerces with schema validation on, without DTD.
    <xs:element name="variant">
    <xs:complexType>
    <xs:sequence>
    <xs:element ref="ds:default"/>
    <xs:element ref="ts:answer"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    As I understand this element should be "element only": without #text nodes in the dom tree.
    But I get: #text default #text answer #text.
    Can I fix it?
    Thanks
    Justinas

    Do you have white space between the nodes? I believe you can tell the parser to ignore white space that is not required by the schema.

  • Child text node lost with newDomNode()

    Hello,
    I have a simple custom XMLBean compiled from a schema like:
    <?xml version="1.0" encoding="UTF-8"?>
    <schema targetNamespace="http://mydomain.com/xsd/myBean"
         xmlns="http://www.w3.org/2001/XMLSchema"
         xmlns:tns="http://mydomain.com/xsd/myBean"
         elementFormDefault="qualified">
         <simpleType name="MyType">
              <restriction base="double"/>
         </simpleType>
         <element name="MyElement" type="tns:MyType"/>
    </schema>
    An the Java code:
    import com.mydomain.xsd.myBean.*;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    void myMethod() {
    MyElementDocument bean = MyElementDocument.Factory.newInstance();
    bean.setMyElement(3.14d);
    // this prints the the xml with text including 3.14d
    System.out.println(bean.xmlText());
    Element dom = ((Document) bean.newDomNode()) .getDocumentElement();
    The problem is, after getting the DOM object my calling newDomNode(), the Text
    Node for "3.14d" is lost from the DOM tree; i.e. instead of
    <tns:MyElement xmlns:tns="http://mydomain.com/xsd/myBean">3.14d</tns:MyElement>
    I get XML like:
    <tns:MyElement xmlns:tns="http://mydomain.com/xsd/myBean" />
    Question: how come the DOM tree is not complete?
    Any help is very much appreciated.
    -Feng

    I fixed the error by upgrading xbean.jar to the one bundled with WebLogic Servcer
    8.1 SP2 (I originally had the version from WLS 8.1 SP1).
    -Feng
    "Feng Xue" <[email protected]> wrote:
    >
    Hello,
    I have a simple custom XMLBean compiled from a schema like:
    <?xml version="1.0" encoding="UTF-8"?>
    <schema targetNamespace="http://mydomain.com/xsd/myBean"
         xmlns="http://www.w3.org/2001/XMLSchema"
         xmlns:tns="http://mydomain.com/xsd/myBean"
         elementFormDefault="qualified">
         <simpleType name="MyType">
              <restriction base="double"/>
         </simpleType>
         <element name="MyElement" type="tns:MyType"/>
    </schema>
    An the Java code:
    import com.mydomain.xsd.myBean.*;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    void myMethod() {
    MyElementDocument bean = MyElementDocument.Factory.newInstance();
    bean.setMyElement(3.14d);
    // this prints the the xml with text including 3.14d
    System.out.println(bean.xmlText());
    Element dom = ((Document) bean.newDomNode()) .getDocumentElement();
    The problem is, after getting the DOM object my calling newDomNode(),
    the Text
    Node for "3.14d" is lost from the DOM tree; i.e. instead of
    <tns:MyElement xmlns:tns="http://mydomain.com/xsd/myBean">3.14d</tns:MyElement>
    I get XML like:
    <tns:MyElement xmlns:tns="http://mydomain.com/xsd/myBean" />
    Question: how come the DOM tree is not complete?
    Any help is very much appreciated.
    -Feng

  • When double clicking a word with an adjacent br Firefox is reporting the endContainer of the selected range as the parent div, but when selecting with a mouse drag Firefox reports the endContainer is a text node. Is this expected behavior?

    Double click on break and the end container appears to be the parent div, but if you select just break with mouse the end container is a text node. If you continue to drag your mouse past the end of break you also get the parent div. Sample html:<br />
    <br />
    <pre><nowiki><!doctype html>
    <html>
    <body>
    <div id="surroundingDiv1">
    Break<br/>
    </div>
    <p>
    <a href="#" onclick="showSelectionInfo()">Show Selection Info</a>
    </p>
    <label for="output"></label><textarea id="output" rows="20" cols="50"></textarea>
    <script>
    function showSelectionInfo() {
    var range = null;
    var sel = window.getSelection();
    if (sel.rangeCount > 0 && sel.getRangeAt(0).toString() != "") {
    range = sel.getRangeAt(0);
    if (range != null) {
    document.getElementById("output").innerHTML =
    "Text: " + range.toString() +
    "\n\nendContainer - " +
    "\n\tid: " + range.endContainer.id +
    "\n\tnodeName: " + range.endContainer.nodeName +
    "\n\tnodeValue: " + range.endContainer.nodeValue +
    "\n\tnodeType: " + range.endContainer.nodeType +
    "\n\nstartContainer - " +
    "\n\tid: " + range.startContainer.id +
    "\n\tnodeName: " + range.startContainer.nodeName +
    "\n\tnodeValue: " + range.startContainer.nodeValue +
    "\n\tnodeType: " + range.startContainer.nodeType;
    </script>
    </body>
    </html></nowiki></pre>

    In general theory, one now has the Edit button for their posts, until someone/anyone Replies to it. I've had Edit available for weeks, as opposed to the old forum's ~ 30 mins.
    That, however, is in theory. I've posted, and immediately seen something that needed editing, only to find NO Replies, yet the Edit button is no longer available, only seconds later. Still, in that same thread, I'd have the Edit button from older posts, to which there had also been no Replies even after several days/weeks. Found one that had to be over a month old, and Edit was still there.
    Do not know the why/how of this behavior. At first, I thought that maybe there WAS a Reply, that "ate" my Edit button, but had not Refreshed on my screen. Refresh still showed no Replies, just no Edit either. In those cases, I just Reply and mention the [Edit].
    Also, it seems that the buttons get very scrambled at times, and Refresh does not always clear that up. I end up clicking where I "think" the right button should be and hope for the best. Seems that when the buttons do bunch up they can appear at random around the page, often three atop one another, and maybe one way the heck out in left-field.
    While I'm on a role, it would be nice to be able to switch between Flattened and Threaded Views on the fly. Each has a use, and having to go to Options and then come back down to the thread is a very slow process. Jive is probably incapable of this, but I can dream.
    Hunt

Maybe you are looking for

  • How to create a menu for bootcamping at startup

    I boot camped my mac and so did the college I attend. They have a system that lets us choose what start-up disc you want to boot on without pressing any option key or setting the start-up disc from system preferences. Once restart it goes straight to

  • Looking for best soluce to compress a DVC Pro 25 movie 3min

    Hi, (sorry for my poor english, i'm french...) I am looking for a good soluce to compress a DVC Pro 25 movie (during 3minutes). I must to compress this movie to reduce the time to transfert by FTP a 750Mo file, when the file is transfered, i must dec

  • Gaps within(!!) songs!

    iTunes iTunes iTunes... This morning I downloaded an album (or several actually) Some songs in one of the albums are full of gaps of ½ second each, here and there. Tried to fix by shuting down iTunes and restart. Don't help. Now, I don't want a ruine

  • Selecting consecutive two rows

    hi all, i have a table 'sample' with following values SAMPLE COL1 1 1 2 2 2 3 3 4 4 6 6 6 In this column i need to display top two rows with their values... wat i need exactly is shown below!!!! Sample Output of my Query; When i run the query first t

  • Ahh..I think its broken..

    Hey everyone. I got my nano as a gift last week, and charged it and everything and it worked fine for about 4 days, but then my battery got low, and I recharged it and it got low again, but this time (before I had a chance to recharge it) the song ti