Last element in string

Hello all
I am having a string like this:
55.000000; 10.000000; 0.100000; 1.000000; 1.000000; 0.100000; 0.000000; 0.000000; 1.000000; 1.000000; 22.000000; 0.100000; 6144.000000;
The length of the string is not always same. What i want is to have the last element. i.e in this case  6144
One way is to get the string length and using string subset to get the last element. But for this, the length must be always constant.
Is there any other way to get the last element independant of the string length
thanks
Nghtcwrlr
********************Kudos are alwayzz Welcome !! ******************
Solved!
Go to Solution.

Since you have the extra semicolon at the end, I actually grabbed the second-to-last element of the array after the spreadsheet string to array.
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
Attachments:
Get last element.png ‏13 KB

Similar Messages

  • How to select the last elements in a string

    Hi Guys
    I am using UART RS232 protocol and i need to calculate the check sum. My data came in decimal and in the end it must be doubles to manipulate it. So my problem is, for example, the sum of all elemants is in decimal 1742 and in hex is 6CE and i wont only the last two elemants, CE that corresponds to 206 that is the result of my checksum. Can anyone help me? 
    Thanks
    Solved!
    Go to Solution.
    Attachments:
    String last elements.vi ‏9 KB

    Thanks Syrpimp
    My data came from HMI in decimal like the example that i show above. Each cell is a value. You used an array, but i think that i can't use it because it must be done automatically and the data field have variable length. 
    The UART protocol frame has a start frame field that corresponds to two ‘{‘ characters and an end frame field that corresponds to two ‘}’. Additionally, besides the data field, that has variable length, it has a byte that corresponds to the command type and another that is the checksum. The following table illustrates the protocol.
    Bytes considered in checksum
    Command Data
    Start Frame
    Cmd
    (hex)
    Data0
    Data1
    Data2
    Data3
    Data4
    Data5
    Data6
    Data…
    CHK SUM
    End Frame
    1 Byte CHK SUM (sum of all data bytes truncated to 1 byte)
    Fig. 1 UART communication protocol template
    I receive data like this:
    123
    123
    160
    54
    111
    103
    110
    108
    107
    109
    108
    108
    100
    100
    100
    100
    0
    0
    1
    4
    5
    0
    0
    0
    0
    0
    0
    7
    96
    1
    0
    0
    0
    0
    0
    10
    51
    1
    0
    0
    51
    1
    1
    23
    12
    0
    206
    125
    125
    I'm trying explain my doubt the best way i can and i thank you all.

  • How to remove only the last element of spreadsheet string

    I use path to string option to store image path into database and while retrieving the string is again converted into path but it gives out an error as the output of array to spreadsheet string gives out a tab at the end which is unable for the IMAQ read file to recognise.but when i use the path of the image directly into IMAQ readfile the image is opened . so how to remove the tab only at the end of output of the spreadsheet string(whose length can vary)? I have also attached my program with this.
    Attachments:
    retrieve_images_from_DB.vi ‏65 KB
    file_path_to_db_(images).vi ‏40 KB
    create_table_for_images.vi ‏45 KB

    indhu wrote:
    > Thanks for your reply!
    > But my problem is to remove only the last element(which is a tab or an
    > alphabet) from a spreadsheet string of any length.
    If you just want to remove the last character of a string just use the
    String Size function reduce the result by one and wire it together with
    the string to the Split String function.
    Rolf Kalbermatter
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Lots of blank space when printing array with only last element printed

    I have a slight problem I have been trying to figure it out for days but can't see where my problem is, its probably staring me in the face but just can't seem to see it.
    I am trying to print out my 2 dimensional array outdie my try block. Inside the trying block I have two for loops in for the arrays. Within the second for loop I have a while to put token from Stringtokeniser into my 2 arrays. When I print my arrays in this while bit it prints fine however when I print outside the try block it only print the last element and lots of blank space before the element.
    Below is the code, hope you guys can see the problem. Thank you in advance
       import java.io.*;
       import java.net.*;
       import java.lang.*;
       import java.util.*;
       import javax.swing.*;
       public class javaflights4
          public static final String MESSAGE_SEPERATOR  = "#";
          public static final String MESSAGE_SEPERATOR1  = "*";
          public static void main(String[] args) throws IOException
             String data = null;
             File file;
             BufferedReader reader = null;
             file = new File("datafile.txt");
             String flights[] [];
                   //String flightdata[];
             flights = new String[21][7];
             int x = 0;
                   //flightdata = new String[7];
             int y = 0;
             try
                reader = new BufferedReader(new FileReader(file));   
                //data = reader.readLine();   
                while((data = reader.readLine())!= null)   
                   data.trim();
                   StringTokenizer tokenised = new StringTokenizer(data, MESSAGE_SEPERATOR1);
                   for(x = 0; x<=flights.length; x++)
                      for(y = 0; y<=flights.length; y++)
                         while(tokenised.hasMoreTokens())
                            //System.out.println(tokenised.nextToken());
                            flights [x] [y] = tokenised.nextToken();
                            //System.out.print("*"+ flights [x] [y]+"&");
                   System.out.println();
                catch(ArrayIndexOutOfBoundsException e1)
                   System.out.println("error at " + e1);
                catch(Exception e)
                finally
                   try
                      reader.close();
                      catch(Exception e)
             int i = 0;
             int j = 0;
             System.out.print(flights [j]);
    //System.out.println();

    A number of problems.
    First, I bet you see a lot of "error at" messages, don't you? You create a 21x7 array, then go through the first array up to 21, going through the second one all the way to 21 as well.
    your second for loop should go to flights[x].length, not flights.length. That will eliminate the need for ArrayIndexOutOfBounds checking, which should have been an indication that you were doing something wrong.
    Second, when you get to flights[0][0] (the very first iteration of the inner loop) you are taking every element from the StringTokenizer and setting flights[0][0] to each, thereby overwriting the previous one. There will be nothing in the StringTokenizer left for any of the other (21x7)-1=146 array elements. At the end of all the loops, the very first element in the array (flights[0][0]) should contain the last token in the file.
    At the end, you only print the first element (i=0, j=0, println(flight[ i][j])) which explains why you see the last element from the file.
    I'm assuming you have a file with 21 lines, each of which has 7 items on the line. Here is some pseudo-code to help you out:
    count the lines
    reset the file
    create a 2d array with the first dimension set to the number of lines.
    int i = 0;
    while (read a line) {
      Tokenize the line;
      count the tokens;
      create an array whose size is the number of tokens;
      stuff the tokens into the array;
      set flights[i++] to this array;
    }

  • Last element of DefaultStyledDocument has \n appended, why?

    Hello!
    I have some trouble getting the text of styledDocument in JTextPane. I get the text recursively by traversing the Elements and convert that to xml and save it. I do not understand why I get \n as last leaf-Element. There is no \n when I call getText in Document or JTextPane. So with every saving and loading the document gets longer and longer because there is \n appended every time.
    Here is a small program that shows the problem:
    import javax.swing.*;
    import javax.swing.text.*;
    public class TextPaneWriter extends JFrame {
         public TextPaneWriter() {
              DefaultStyledDocument doc = new DefaultStyledDocument();
              try {
                   SimpleAttributeSet a = new SimpleAttributeSet();
                   StyleConstants.setBold(a, true);
                   doc.insertString(doc.getLength(),
                             "I wish I was in Carrickfergus\n", a);
                   a = new SimpleAttributeSet();
                   StyleConstants.setItalic(a, true);
                   doc.insertString(doc.getLength(),
                             "Only for nights in Ballygrant\n", a);
                   a = new SimpleAttributeSet();
                   StyleConstants.setUnderline(a, true);
                   doc.insertString(doc.getLength(),
                             "I would swim over the deepest ocean,\n", a);
                   a = new SimpleAttributeSet();
                   StyleConstants.setBold(a, true);
                   doc.insertString(doc.getLength(),
                             "For my love to find", a);
              catch (BadLocationException x) {
              JTextPane tp = new JTextPane(doc);
              this.getContentPane().add(tp);
              System.out.println("Get text of JTextPane:");
              System.out.println(tp.getText() + "END");
              System.out.println();
              System.out.println("Get text of Document:");
              try {
                   System.out.println(doc.getText(0, doc.getLength()) + "END");
              catch (BadLocationException x) {
              System.out.println();
              System.out.println("Get text recursively:");
              this.writeDocRec(doc.getDefaultRootElement(), doc);
              this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              this.setSize(200,200);
              this.setVisible(true);
         private String getTextOfElement(Element styledElement,
                   DefaultStyledDocument doc) {
              String text = "";
              int startOffset = styledElement.getStartOffset();
              int endOffset = styledElement.getEndOffset();
              try {
                   text = doc.getText(startOffset, endOffset-startOffset);
              catch (BadLocationException x) {
                   x.printStackTrace();
              return text;
         private void writeDocRec(javax.swing.text.Element element,
                   DefaultStyledDocument doc) {
              if (element.isLeaf()) return;
              for (int i=0; i<element.getElementCount(); i++) {
                   javax.swing.text.Element child = element.getElement(i);
                                  if (child.isLeaf()) {
                        System.out.print(this.getTextOfElement(child, doc) + "END OF ELEMENT\n");
                   writeDocRec(child, doc);
          * @param args
         public static void main(String[] args) {
              new TextPaneWriter();
    }And this is what I am getting:
    Get text of JTextPane:
    I wish I was in Carrickfergus
    Only for nights in Ballygrant
    I would swim over the deepest ocean,
    For my love to findEND
    Get text of Document:
    I wish I was in Carrickfergus
    Only for nights in Ballygrant
    I would swim over the deepest ocean,
    For my love to findEND
    Get text recursively:
    I wish I was in Carrickfergus
    END OF ELEMENT
    Only for nights in Ballygrant
    END OF ELEMENT
    I would swim over the deepest ocean,
    END OF ELEMENT
    For my love to findEND OF ELEMENT
    END OF ELEMENT
    So why is there another element with \n?
    I can only think of digging in the xml-document after parsing finding the last element and removing the last \n. Or is it \n\r or \r\n?!?!? It does not feel good to do something like that........
    Thank you!
    Annette
    Message was edited by:
    Annette

    Sometimes a bit of sleep is better than any thinking!
    I had an idea this morning and it seams to be working. I change the recursive method to:
         private void writeDocRec(javax.swing.text.Element element,
                   DefaultStyledDocument doc) {
              if (element.isLeaf()) return;
              for (int i=0; i<element.getElementCount(); i++) {
                   javax.swing.text.Element child = element.getElement(i);
                   if (child.isLeaf()) {
                        int start = child.getStartOffset();
                        int end = child.getEndOffset();
                        int len = doc.getLength();
                        if (end > len) System.out.println("len " + len
                                  + " start " + start + " end " + end);
                        else System.out.print(this.getTextOfElement(child, doc)
                                  + "END OF ELEMENT\n");
                   writeDocRec(child, doc);
         }I found that the last element, that I do NOT want and that contains that \n has endIndex > doc.getLength(). So if I find an element that satisfies this condition I know it is the last, not wanted element, and skip it. Does it make any sense to have an element with index > length?
    Do you think that this is a good solution? Or is it some kind of trial and error and not really understanding what is going on?
    I would appreciate some advices. Thank you!
    Annette

  • How to get the last element of a structure in a textfield in DesignStudio

    Hello,
    how can I get the last element of a structure within a bex query?
    Within the structure we are working with dates that dynamically are buiId (input date - offsets for several months).
    I have to show the last value in a single textfield within DesignStudio.
    Regards
    Frank

    Hi Frank,
    in DS 1.3 you can use forEach function to get the last element of BEx structure (or n-th element in general using if condition)
    var array = DS_CROSSTAB1.getMembers("DHGY5D6XEFO1K45SB00BXFH7A",10);
    var lastMember="";
    array.forEach(function(element, index) {
           lastMember = element.text;
    TEXT_1.setText("Last structure element: "+lastMember);

  • How to delete the last element of a collection without iterating it?

    how to delete the last element of a collection without iterating it?

    To add to jverd's reply, even if you could determine the last element, in some collections it is not guaranteed to always be the same.
    From HashSet:
    It makes no guarantees as to the iteration order of the set; in particular, it does not guarantee that the order will remain constant over time.

  • XML Element to string conversion returning null

    Hi,
    When i try to convert XML Element to string using toString() API, it returns something like [device: null] where device is element tag.
    Code is as follows -
    Document xmlDoc;
    DOMParser parser = (DOMParser)Class.forName("org.apache.xerces.parsers.DOMParser").newInstance();
    parser.setFeature( "http://apache.org/xml/features/dom/defer-node-expansion", true );
    parser.parse(new InputSource(new StringReader(tableStr)));
    xmlDoc = parser.getDocument();
    Element root = xmlDoc.getDocumentElement();
    NodeList nodeList = root.getElementsByTagName("device");
    Element deviceNode = (Element)nodeList.item(nodeList.getLength()-1);
    System.out.println(deviceNode.toString()); //prints [device: null] ????
    System.out.println(deviceNode.getAttribute("ipAddress")); //prints correct ip address
    Any idea why i am getting [device: null] when trying to convert Element to String though attribute value is retrieved.
    Thanks,
    Deepak

    Hello ,
    I want to get the root node (<ZTOP60_XML_TAG_STRUCTURE>
    ) of the following xml file .
    <?xml version="1.0" encoding="utf-8"?>
    <ZTOP60_XML_TAG_STRUCTURE>
         <MSGTYPE>NAPOBACK</MSGTYPE>
         <SNDPRN>657393485</SNDPRN>
         <RECEIVER/>
         <RCVPRN>GSOHUBDM1</RCVPRN>
         <PONUM/>
         <VENDCODE>0020040266</VENDCODE>
         <VENDUNS>002601768</VENDUNS>
         <PARTNERFUNC_WE>WE</PARTNERFUNC_WE>
         <PARTNERNUM_WE>C240</PARTNERNUM_WE>
         <LINE_ITEMS>
              <item>
                   <ITEMNUM>00687</ITEMNUM>
                   <POQTY>999999999.000</POQTY>
                   <BOQTY>1.000</BOQTY>
                   <GRQTY>7.000</GRQTY>
                   <NETVAL>339.65</NETVAL>
                   <PLANT>C240</PLANT>
                   <MATNUM>FE-26865-01</MATNUM>
                   <MATDESC>PTR, T632, LEXMARK 5-BIN MAILBOX</MATDESC>
                   <PONUMBER>6500022388</PONUMBER>
                   <EKGRP>U17</EKGRP>
                   <DISPO>N07</DISPO>
              </item>
              <item>
                   <ITEMNUM>00178</ITEMNUM>
                   <POQTY>999999999.000</POQTY>
                   <BOQTY>1.000</BOQTY>
                   <GRQTY>303.000</GRQTY>
                   <NETVAL>18.62</NETVAL>
                   <PLANT>C240</PLANT>
                   <MATNUM>FE-ZZYRG-01</MATNUM>
                   <MATDESC>FDD,FDI-PC,1.44MB,3.5 ,HH</MATDESC>
                   <PONUMBER>6500022388</PONUMBER>
                   <EKGRP>U17</EKGRP>
                   <DISPO>N07</DISPO>
              </item>
              <item>
                   <ITEMNUM>00157</ITEMNUM>
                   <POQTY>999999998.000</POQTY>
                   <BOQTY>24.000</BOQTY>
                   <GRQTY>303.000</GRQTY>
                   <NETVAL>26.25</NETVAL>
                   <PLANT>C240</PLANT>
                   <MATNUM>FE-25094-01</MATNUM>
                   <MATDESC>MOUSE,PC,3BUT,,INTELLIMOUSE,PS2</MATDESC>
                   <PONUMBER>6500022388</PONUMBER>
                   <EKGRP>U17</EKGRP>
                   <DISPO>N07</DISPO>
              </item>
              <item>
                   <ITEMNUM>00881</ITEMNUM>
                   <POQTY>999999999.000</POQTY>
                   <BOQTY>1.000</BOQTY>
                   <GRQTY>62.000</GRQTY>
                   <NETVAL>368.80</NETVAL>
                   <PLANT>C240</PLANT>
                   <MATNUM>FD-66515-01</MATNUM>
                   <MATDESC>ITU MODULE ASM</MATDESC>
                   <PONUMBER>6500022388</PONUMBER>
                   <EKGRP>U17</EKGRP>
                   <DISPO>N07</DISPO>
              </item>
              <item>
                   <ITEMNUM>00223</ITEMNUM>
                   <POQTY>999999999.000</POQTY>
                   <BOQTY>1.000</BOQTY>
                   <GRQTY>377.000</GRQTY>
                   <NETVAL>459.28</NETVAL>
                   <PLANT>C240</PLANT>
                   <MATNUM>FD-65336-01</MATNUM>
                   <MATDESC>MAIN SYSTEM BOARD T23 (2647)</MATDESC>
                   <PONUMBER>6500022388</PONUMBER>
                   <EKGRP>U17</EKGRP>
                   <DISPO>N07</DISPO>
              </item>
              <item>
                   <ITEMNUM>00081</ITEMNUM>
                   <POQTY>999999999.000</POQTY>
                   <BOQTY>19.000</BOQTY>
                   <GRQTY>810.000</GRQTY>
                   <NETVAL>217.21</NETVAL>
                   <PLANT>C240</PLANT>
                   <MATNUM>FD-64199-01</MATNUM>
                   <MATDESC>QST- CADET 100</MATDESC>
                   <PONUMBER>6500022388</PONUMBER>
                   <EKGRP>U17</EKGRP>
                   <DISPO>N07</DISPO>
              </item>
              <item>
                   <ITEMNUM>00271</ITEMNUM>
                   <POQTY>999999999.000</POQTY>
                   <BOQTY>1.000</BOQTY>
                   <GRQTY>136.000</GRQTY>
                   <NETVAL>813.76</NETVAL>
                   <PLANT>C240</PLANT>
                   <MATNUM>FD-60065-01</MATNUM>
                   <MATDESC>SMART UPS 3000VA RM</MATDESC>
                   <PONUMBER>6500022388</PONUMBER>
                   <EKGRP>U17</EKGRP>
                   <DISPO>N07</DISPO>
              </item>
              <item>
                   <ITEMNUM>00791</ITEMNUM>
                   <POQTY>999999999.000</POQTY>
                   <BOQTY>1.000</BOQTY>
                   <GRQTY>3.000</GRQTY>
                   <NETVAL>201.73</NETVAL>
                   <PLANT>C240</PLANT>
                   <MATNUM>3X-PBXGG-AA</MATNUM>
                   <MATDESC>ATI 7500 PCI GRAPHICS</MATDESC>
                   <PONUMBER>6500022388</PONUMBER>
                   <EKGRP>U17</EKGRP>
                   <DISPO>N07</DISPO>
              </item>
              <item>
                   <ITEMNUM>00173</ITEMNUM>
                   <POQTY>999999999.000</POQTY>
                   <BOQTY>1.000</BOQTY>
                   <GRQTY>32.000</GRQTY>
                   <NETVAL>7.50</NETVAL>
                   <PLANT>C240</PLANT>
                   <MATNUM>12-56178-01</MATNUM>
                   <MATDESC>CARD GUIDE,SNAP-IN,LOW PROFILE,2.5 INCHE</MATDESC>
                   <PONUMBER>6500022388</PONUMBER>
                   <EKGRP>U17</EKGRP>
                   <DISPO>N07</DISPO>
              </item>
              <item>
                   <ITEMNUM>00309</ITEMNUM>
                   <POQTY>999999998.000</POQTY>
                   <BOQTY>15.000</BOQTY>
                   <GRQTY>71.000</GRQTY>
                   <NETVAL>51.23</NETVAL>
                   <PLANT>C240</PLANT>
                   <MATNUM>30-51476-01</MATNUM>
                   <MATDESC>VHDI-CABLE WIDE 12 FT. DT-AB001-TQ</MATDESC>
                   <PONUMBER>6500022388</PONUMBER>
                   <EKGRP>U17</EKGRP>
                   <DISPO>N07</DISPO>
              </item>
              <item>
                   <ITEMNUM>00194</ITEMNUM>
                   <POQTY>999999999.000</POQTY>
                   <BOQTY>1.000</BOQTY>
                   <GRQTY>147.000</GRQTY>
                   <NETVAL>345.48</NETVAL>
                   <PLANT>C240</PLANT>
                   <MATNUM>29-33689-01</MATNUM>
                   <MATDESC>PTR,IMP9,B/W,PAR/SER,110/240,R</MATDESC>
                   <PONUMBER>6500022388</PONUMBER>
                   <EKGRP>U17</EKGRP>
                   <DISPO>N07</DISPO>
              </item>
         </LINE_ITEMS>
    </ZTOP60_XML_TAG_STRUCTURE>
    I wrote the following lines of code ..
    FTI .. >> String strMsg =((javax.jms.TextMessage)msg).getText();
    StrMsg is a string that represents an xml file .
    DocumentBuilderFactory docfactory = DocumentBuilderFactory.newInstance();
                   DocumentBuilder builder = docfactory.newDocumentBuilder();
                   Document doc = builder.parse(new InputSource(new StringReader(strMsg)));
                   Element root = doc.getDocumentElement();
                   System.out.println("The root is " + root);
                   String strFileName = root+".xml" ;
                   System.out.println("The file name is " + strFileName);
                   File f = new File (strFileName);
                   FileOutputStream fos = new FileOutputStream( f );
                   for ( int j =0 ; j < strMsg.length(); j++)
                        char c = strMsg.charAt(j);
                        fos.write((int)c);
    I am getting the following error ...
    The root is [ZTOP60_XML_TAG_STRUCTURE: null]
    The file name is [ZTOP60_XML_TAG_STRUCTURE: null].xml
    Whey the file name or root is with special character [ ] and null ..
    I want just ZTOP60_XML_TAG_STRUCTURE.xml .
    Can anyone help me .
    thanks
    mahesh

  • Got last letter in String

    HI all ,
    how to got the right part of my string in java?
    String Name =req.getParameter("Horst");in sql i can use
    SELECT right(Name, 2) to got the last letter in string , but when I modify the code as Syear="SELECT right('"+Name+"', 2)"; I got error . is java have function to got last letter in string??
    thank you!

    String s1 = "HELLO";
    String s2 = s1.substring(s1.length() - 1);

  • JComboBox shows "Java Applet Window" as last element

    Hey all,
    I am having a problem with using JComboBox. When I use JComboBox and show it in a JDialog (popup window), the last element of the drop down (JComboBox) is "Java Applet Window". This element is, however, not selectable. I want to get rid fo the "Java Applet Window" in my dropdown.
    This problem only happens when my applet opens up a JDialog that has the JComboBox, but does not happen when I add the JComboBox directly to the applet.
    I've read around in other forums that this has to do with security. I understand the need to show that a popup window (JDialog) is an applet window so the user doesn't mistake it as one of the native windows. But, the JComboBox is not a whole 'nother window, so why does it feel the needs to add that last line to designate it as a "Java Applet Window?"
    Thanks.
    Nina.

    My apologies, I did not clarify myself in my question. Sorry that I created misunderstandings of the problem - as evident in the response in the previous post from himanshug.
    I am using JDK 1.3.1
    I must use an applet, but all my components are standalone. They can be ran as a standalone application. But for deployment, we are using applets. It's easier to do applets so clients can access via browser than deploy a whole application installation on 50 machines halfway across the world.
    And no, there is no element in my list that says "Java Applet Window". When running my application standalone, the "Java Applet Window" does not appear as the last element in my drop down.
    The "Java Applet Window" also does NOT appear when I add the drop down directly to the applet. It only appears when the drop down is in a JDialog that gets launched by an applet.
    My problem: How to get rid of the "Java Applet Window" as it seems something is adding this to my dropdown. And it's not my code that is adding it.
    Thanks. I am also up'ing the duke dollars for a solution to this to 15.

  • How to display last element in a dynamic 1d array

    hi..
    i want to display the value of last element in a 1d dynamic array.../ i mean ..if i stop the vi run, i need to display the last element in the array..how can i do this?
    and is there any way to use a button to start the vi...instead of using the Run button on the vi front panel??
    Solved!
    Go to Solution.

    Index array!.  Use array size to determine the size of your array, subtract 1, feed that in the index terminal of Index Array.
    You have to start the VI running somehow.  It could be set to run when opened.  Assuming what you want is a means to type values into a front panel, hit a GO button that you created on the front panel, then have the real part of the VI execute.  You could use an event structure.  Or put a while loop at the beginning with a small wait statement in side that basically just polls the GO button.  When that button is pressed, the true boolean stops the while loop and allows the program to proceed to the main body of your program.

  • BPM xpath issue with last-index-within-string

    Hey all,
    I have a script task in BPM that updates a field by using multiple xpath functions. I have narrowed the issue down to the oraext:last-index-within-string function.
    If I do something like oraext:last-index-within-string('ora/in/ok/d', '/').....I get 9 like expected.
    But if I base it off the request data like so:
    oraext:last-index-within-string(bpmn:getDataObject('Request')/ns:document/ns1:dDocAccount, '/')........when I go to em I have an internal xpath error.
    I'm assuming it has something to do with using bpmn:getDataObject as a parameter. But I'm not sure what. If I use the getDataObject as a parameter in substring like so:
    substring(bpmn:getDataObject('Request')/ns:document/ns1:dDocAccount, 8)....it works as expected.
    What is it about the combination with last-index-within-string that is giving me an issue??
    Thanks
    John

    Got it. Apparently, sometimes with xpath, you have to concatenate the variable with an empty string to change it into a string....sometimes, but not all the time...yay.... I'm guessing the xpath inbuilt functions already know to convert the variable passed in into a string, whereas the oraext functions don't. I could be completely wrong on that though...:-P . Anyway, this works:
    oraext:last-index-within-string(concat(bpmn:getDataObject('Result')/ns:document/ns1:dDocAccount, ''), '/')
    Thanks,
    John

  • Covert DOM element to String

    It sounds very simple, however could not find any solution using JAXP.
    What I need is that I have a DOM element, I want to convert the DOM element into String and store into the database. I used to do it using JDOM. It has a feature something like toString.
    I know that serialization is another option, however, want to know how to do this way.

    xmlString.getBytes()No, that causes your problem. Read the documentation to see what the getBytes() method does. Here's what you should do instead:Document document = documentBuilder.parse(new InputSource(new StringReader(xmlString)));This doesn't convert from String to bytes using a bad encoding. But you also say:
    xmlString contains Japanese characters and was originally from a xml file with UTF-8 encoing.In this case there's a good chance that in reading from the file to the String you have also failed to use UTF-8 to do the decoding. Why not just pass a File object to the parser and let it deal with the encoding issues? It knows what to do.

  • Dom element to string

    I have a method, the argument being passed in is a dom element.
    The method will convert the element(and child node) to string. The string is then passed into a buffer writer to write to a file.
    What is the easiest/fastest way to convert the dom element to string?
    Is there a better way to write the element to a file?
    Any sample code available?

    You could try something like this:
        String elementToString(Element element)
        throws Exception
            StringWriter sw = new StringWriter();
            TransformerFactory tFactory = TransformerFactory.newInstance();
            Transformer transformer = tFactory.newTransformer();
            transformer.setOutputProperty(OutputKeys.INDENT, "yes");
            transformer.setOutputProperty(OutputKeys.METHOD, "xml");
            transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
            DOMSource source = new DOMSource(element);
            StreamResult result = new StreamResult(sw);
            transformer.transform(source, result);
            return sw.toString();
        }Regards

  • Last element in structure

    hey all-
    i am trying to add a comma if this is last element in
    structure:
    <cfset stuff=structnew()>
    <cfset stuff.first=1>
    <cfset stuff.first_first=2>
    <cfset stuff.first_first_first=3>
    <cfset stuff.first_first_first_first=4>
    <cfset stuff.first_first_first_first_first=5>
    <cfdump var="#stuff#">
    <cfoutput>
    <cfloop collection="#stuff#" item="i">
    '#stuff
    #'<cfif StructCount(stuff) lt 6>,</cfif>
    </cfloop>
    </cfoutput>
    but it is not workin. how do i get the last
    element.

    As Adam said structures are unordered and there is no concept
    of last.
    But it looks like you are trying to output a list of elements
    by looping
    over the structure and do not want a comma after the last
    element. Your
    if logic is the problem here, it will always be true.
    <cfoutput>
    <cfloop collection="#stuff#" item="i">
    '#stuff
    #'<cfif StructCount(stuff) lt 6>,</cfif>
    </cfloop>
    </cfoutput>
    StructCount(stuff) is always five. It the size of the
    structure is not
    going to change while you are looping over it. You need a
    counter and
    then compare that counter to the size of the structure to
    know you have
    reached the end of it.
    <cfoutput>
    <cfset counter = 0>
    <cfloop collection="#stuff#" item="i">
    <cfset counter = counter + 1>
    '#stuff#'<cfif counter lt
    StructCount(stuff)>,</cfif>
    </cfloop>
    </cfoutput>
    This could be simplified with a list function.
    <cfset stuffList = ''>
    <cfloop collection="#stuff#" item="i">
    <cfset stuffList = listAppend(stuffList,stuff
    )>
    </cfloop>
    <cfoutput>#stuffList#</cfoutput>

Maybe you are looking for

  • Cisco Network Assistant, unable to add a switch

    I have a network running some 20 switches, two controllers and many AP's.  All the devices that should be able to connect to cisco network assistant can successfully.  However there is one switch that will show in neighbours but will give the message

  • [Solved]my netbook got stuck in rootfs after update (EEE PC 1005HA)

    Hi guys!! So, yesterday i've updated the system. everything goes normal. today, when i turned it on, it got stuck in rootfs. i don't know what happened, if that behaviour is my fault or my system got crazy... i've searched about this problem but i fo

  • Ipod speeds up like crazy - iphone 4

    I have an iphone 4, and am having a problem with the ipod function. After about 15 min of use (always when I'm running) the songs start speeding up like crazy and sometimes it won't even stop when I press stop, pause, etc. Anyone else have this? Any

  • Initialize 2 dimensions arrays

    Hi everybody. Im using Oracle 11g, on Linux Centos. My problem is with 2 dimensions array. I have defined a type in the database in this way : create or replace TYPE ARRAY_N_12 is varray(12) of number; Now I try to do the next : create or replace pro

  • Ready to take the Iphone plunge......................

    I have had two Android phones. And while my experience with them has not been terrible, it has left something to be desired. So when my contract is up in early December I am seriously thinking of going with the Iphone 5 ( or whatever it will ultimate