Parse Serial Data

I am communicating with an instrument that takes a query and puts out a status packet. I have to parse the data and get information about the instrument status. The status packet is a multi byte data with MSB first and all bytes are 8 bit.
I get a string output with that says something like this..."CC\B0\CC\B0\CC\D0\CC\D0\CC\B0\CC\D0\00\...". I have not posted the entire string. But I need to parse thsi string and get meaningful values out of it.
I read some of the previous posts which suggest using the Type Cast function. But I am not sure how it works and how to use it. Also tried using the String to Byte Array function but do not know how to use the array to obatin values that correspond to a voltage.
Thanks.

LabVIEW uses Big Endian format for its binary numbers, while most Windows programs use Little Endian format. LabVIEW uses Big Endian, because that is what the MacOS uses, and LabVIEW was created first for the Macintosh. So must test and see what is correct.  In my example I have assumed that the datatype is I16, but it could also be U16
Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
Attachments:
demo.vi ‏9 KB

Similar Messages

  • Searching Incoming Serial Data

    Greetings!
    I was trying to get visual studio to filter through the incoming serial data it is receiving from an Arduino. The program shows the incoming data, so I know the serial port is working, but I'm not sure how to get it to look through that data ( I was thinking
    I could use StreamReader to do this). My goal is this: When certain data is received, change the background color of a textbox. I am very new at this and any direction would be appreciated! I feel like i'm throwing spaghetti at a wall... 
    Here is my current code:
    Imports System
    Imports System.Threading
    Imports System.IO.Ports
    Imports System.ComponentModel
    Imports System.IO
    Public Class Form1
    Dim myPort As Array
    Delegate Sub SetTextCallBack(ByVal [TEXT] As String)
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    myPort = IO.Ports.SerialPort.GetPortNames()
    portCmbo.Items.AddRange(myPort)
    End Sub
    Private Sub startBtn_Click(sender As Object, e As EventArgs) Handles startBtn.Click
    SerialPort1.PortName = portCmbo.Text
    SerialPort1.BaudRate = baudCmbo.Text
    SerialPort1.Open()
    startBtn.Enabled = False
    closeBtn.Enabled = True
    End Sub
    Private Sub closeBtn_Click(sender As Object, e As EventArgs) Handles closeBtn.Click
    SerialPort1.Close()
    startBtn.Enabled = True
    closeBtn.Enabled = False
    End Sub
    Private Sub SerialPort1_DataReceived(sender As Object, e As SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
    ReceivedText(SerialPort1.ReadExisting())
    End Sub
    Private Sub ReceivedText(ByVal [text] As String)
    If Me.inputTxtBox.InvokeRequired Then
    Dim x As New SetTextCallBack(AddressOf ReceivedText)
    Me.Invoke(x, New Object() {(text)})
    Else
    Me.inputTxtBox.Text &= [text]
    End If
    End Sub
    Private Sub outputTxtBx_TextChanged(sender As Object, e As EventArgs) Handles outputTxtBx.TextChanged
    Dim myReader As StreamReader = New StreamReader("Me.inputTxtBox")
    Dim line As String = ""
    End Sub
    End Class
    ps: If there is an easier way of doing this, please let me know!

    You should read a good book on "Communications".  When processing received data (from any device) you need to wait until you get the end of message before parsing the data.  The data will be received in chunks that can contain from 1
    to a million bytes.  When you get the word "Hello" you could get "H" then "ello" or "Hel" and then "lo".  You can't start looking through the data until you get the entire word "Hello". 
    So you first have to define a protocol for sending commands to the device and the amount of data that gets returned.  So normally you have to terminate a message using one of the following methods
    1) Ascii : Terminate a message with a fix character like a return or EOM.
    2) Ascii or binary : Includes a bytes count at the beginning of the message.
    3) Ascii or binary : Each type message is a fixed length.
    You can use combination of the 3 methods above.
    jdweng

  • Reading and analyzing serial data

    Hello,
    My question is about interpreting periodic serial data.
    I'm trying to read a serial rs232 port, through which I'm receiving periodic data which is made up of 4 repeating messages.
    Each message consists of several parameters of various length and fomates (for example, the first parameter could be an unisgned byte while the second parameter could be a word-long float). Each message begins and terminates with known character sequences.
    I need to read this periodic data and display it to the user, so that each of the parameters (of which the messages are made) is displayed
    by a different indicator.
    Right now, I've used the basic read/write rs232 LabView tutorial but now I'm pretty much stuck...
    I've built a similar program using Visual Basic and I've started using LabView in order to build better user interfaces but so far I'm stuck...
    Any suggestions?

    First, I think you really could have come up with a better user name then falling asleep on your "N" key.
    Data that comes in through the serial port is a string.  So your problem really comes down to how to parse the string into its respective parts.  Look at the functions on the string pallete.  Functions such as Match String, Search/Split String, or Scan String for Tokens, should do what you need.  Once you have the parts broken up, the String to Number conversion functions would convert the strings into their appropriate datatypes.

  • Serial Data Record Timing

    I was wondering if I might get some help in debugging some timing issues for my serial data recording.  Currently I am trying to create a loop that records data from a meter that outputs a comma-delimited string every 5 seconds.  I have attached the VI that I am currently trying to debug.
    The problem I am facing now is that sometimes I am not catching the correct string.  It is catching either the tail end of a previous print, and then the read buffer is never cleared, so the data needed array cells 5, and 11 are not correct.
    I was thinking that somehow I could simply wait on the data to arrive, do the reading etc, then wait 5 sec for the next bit of data -> or simply wait for the next complete string.  If anyone has any suggestions please let me know, and code examples would be great.
    Please let me know if you have any questions.
    Thanks
    Attachments:
    test_serial.vi ‏167 KB

    Hi Vessel,
    I noticed another point: I suppose, your meter is configured to send this string every five seconds. Since the timing of your meter and the PC is not exactly the same, you have some timing interference effects, so that after a while your "Bytes at Port"- node executes, while the meter is sending the data (9600 Baud is not very fast). That's why you get only parts of the string.
    A better approach to this problem would be to periodically call the "Bytes at Port"- node until the expected amount of Bytes is given back (if you expect a defined number of bytes). Or you read in all data you receive in a short time loop and check for some end-of-String condition, after this you can parse the String for the coma-separated values.
    Perhaps I could help you, maybe you post your solution to the problem,
    Dave
    Greets, Dave

  • Script for parsing xml data and inserting in DB

    Thank you for reading.
    I have the following example XML in an XML file. I need to write a script that can insert this data into an Oracle table. The table does not have primary keys. The data just needs to be inserted.
    I do not have xsd file in this scenario. Please suggest how to modify Method 1 https://community.oracle.com/thread/1115266?tstart=0 mentioned so that I can call the XML mentioned below and insert into a table
    Method 1
    Create or replace procedure parse_xml is 
      l_bfile   BFILE; 
      l_clob    CLOB; 
      l_parser  dbms_xmlparser.Parser; 
      l_doc     dbms_xmldom.DOMDocument; 
      l_nl      dbms_xmldom.DOMNodeList; 
      l_n       dbms_xmldom.DOMNode; 
      l_file      dbms_xmldom.DOMNodeList; 
      l_filen       dbms_xmldom.DOMNode; 
      lv_value VARCHAR2(1000); 
       l_ch      dbms_xmldom.DOMNode; 
    l_partname varchar2(100); 
    l_filename varchar2(1000); 
      l_temp    VARCHAR2(1000); 
      TYPE tab_type IS TABLE OF tab_software_parts%ROWTYPE; 
      t_tab  tab_type := tab_type(); 
    BEGIN 
      l_bfile := BFileName('DIR1', 'SoftwareParts.xml'); 
      dbms_lob.createtemporary(l_clob, cache=>FALSE); 
      dbms_lob.open(l_bfile, dbms_lob.lob_readonly); 
      dbms_lob.loadFromFile(dest_lob => l_clob,    src_lob  => l_bfile,    amount   => dbms_lob.getLength(l_bfile)); 
      dbms_lob.close(l_bfile);  
      dbms_session.set_nls('NLS_DATE_FORMAT','''DD-MON-YYYY'''); 
      l_parser := dbms_xmlparser.newParser; 
      dbms_xmlparser.parseClob(l_parser, l_clob); 
      l_doc := dbms_xmlparser.getDocument(l_parser); 
        dbms_lob.freetemporary(l_clob); 
      dbms_xmlparser.freeParser(l_parser); 
      l_nl := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(l_doc),'/PartDetails/Part'); 
        FOR cur_emp IN 0 .. dbms_xmldom.getLength(l_nl) - 1 LOOP 
        l_n := dbms_xmldom.item(l_nl, cur_emp); 
        t_tab.extend; 
        dbms_xslprocessor.valueOf(l_n,'Name/text()',l_partname); 
        t_tab(t_tab.last).partname := l_partname; 
        l_file := dbms_xslprocessor.selectNodes(l_n,'Files/FileName'); 
        FOR cur_ch IN 0 .. dbms_xmldom.getLength(l_file) - 1 LOOP 
          l_ch := dbms_xmldom.item(l_file, cur_ch); 
          lv_value := dbms_xmldom.getnodevalue(dbms_xmldom.getfirstchild(l_ch)); 
          if t_tab(t_tab.last).partname is null then t_tab(t_tab.last).partname := l_partname; end if; 
          t_tab(t_tab.last).filename := lv_value; 
        t_tab.extend; 
       END LOOP; 
       END LOOP; 
        t_tab.delete(t_tab.last); 
      FOR cur_emp IN t_tab.first .. t_tab.last LOOP 
      if t_tab(cur_emp).partname is not null and  t_tab(cur_emp).filename is not null then 
        INSERT INTO tab_software_parts 
        VALUES 
        (t_tab(cur_emp).partname, t_tab(cur_emp).filename); 
        end if; 
      END LOOP; 
      COMMIT; 
      dbms_xmldom.freeDocument(l_doc); 
    EXCEPTION 
      WHEN OTHERS THEN 
        dbms_lob.freetemporary(l_clob); 
        dbms_xmlparser.freeParser(l_parser); 
        dbms_xmldom.freeDocument(l_doc); 
    END; 
    <TWObject className="TWObject">
      <array size="240">
        <item>
          <variable type="QuestionDetail">
            <questionId type="String"><![CDATA[30]]></questionId>
            <questionType type="questionType"><![CDATA[COUNTRY]]></questionType>
            <country type="String"><![CDATA[GB]]></country>
            <questionText type="String"><![CDATA[Please indicate]]></questionText>
            <optionType type="String"><![CDATA[RadioButton]]></optionType>
            <answerOptions type="String[]">
              <item><![CDATA[Yes]]></item>
              <item><![CDATA[No]]></item>
            </answerOptions>
            <ruleId type="String"><![CDATA[CRP_GB001]]></ruleId>
            <parentQuestionId type="String"></parentQuestionId>
            <parentQuestionResp type="String"></parentQuestionResp>
          </variable>
        </item>
        <item>
          <variable type="QuestionDetail">
            <questionId type="String"><![CDATA[40]]></questionId>
            <questionType type="questionType"><![CDATA[COUNTRY]]></questionType>
            <country type="String"><![CDATA[DE]]></country>
            <questionText type="String"><![CDATA[Please indicate]]></questionText>
            <optionType type="String"><![CDATA[RadioButton]]></optionType>
            <answerOptions type="String[]">
              <item><![CDATA[Yes]]></item>
              <item><![CDATA[No]]></item>
            </answerOptions>
            <ruleId type="String"><![CDATA[CRP_Q0001]]></ruleId>
            <parentQuestionId type="String"></parentQuestionId>
            <parentQuestionResp type="String"></parentQuestionResp>
          </variable>
        </item>
      </array>
    </TWObject>

    Reposted as
    Script to parse XML data into Oracle DB

  • How do you store parsed XML data in an array

    Hi, i am trying to complete a small program which implements the SAX parser to parse an XML file. My problem is that i am writing a custom class to store the parsed data into an array, and then make the array available to the main program via a simple method which returns the array. I know this must be very simple to do, but i seem to have developed a mental block with this part of the program. I can parse the data and print all the elements to the screen, but i just cant figure out how to store all the data elements into the array. I will post the class which is supposed to do this, and ask anyone out there if they know what i'm doing wrong, and also, if there is a more effeicient way of achieving this ( i expect there definitely is!! but i have never used the SAX parser before and am getting confused by the API docs on it!!) Any help very much appreciated.
    Here is my attempt at coding the class to handle the parsed XML data
    class Sink extends org.xml.sax.helpers.DefaultHandler
         implements org.xml.sax.ContentHandler{
    Customer[] customers = new Customer[20];
         int count = 1;
         int x = 0;
         int tagCount = 0;
         String name;
    String custID;
         String username;
         String address;
         String phoneNum;
    public void startElement(String uri, String localName, String rawName, final org.xml.sax.Attributes attributes)throws org.xml.sax.SAXException{
    //count the number of <name> tags in the XML file
         if(rawName.equals("name")){
              tagCount++;
    public void characters(char[] ch, int start, int len){
    //get the current string
         String text = new String(ch, start, len);
         String text1 = text.trim();
    //there are 5 elements for each customer found in the XML file so when the count reaches 6
    // i reset this to 1
         if(count == 6){
         count = count - 5;
         if(text1.length()>0 && count == 1){
              name = text1;
              System.out.println(name);
              }else{
         if(text1.length()>0 && count == 2){
              custID = text1;
              System.out.println(custID);
                   }else{
                   if(text1.length()>0 && count == 3){
                   username = text1;
                   System.out.println(username);
                   }else{
                        if(text1.length()>0 && count == 4){
                        address = text1;
                        System.out.println(address);
                        }else{
                        if(text1.length()>0 && count == 5){
                             phoneNum = text1;
                             System.out.println(phoneNum);
                             //add data to the customer array
                             customers[x] = new Customer(name, custID, username, address, phoneNum);
    // increment the array index counter
                        x = x+1;
                        }//end of if
                        }//end else
                        }//end else
                   }//end else
              }//end else
    }//end of characters method
    public void endDocument(){
         System.out.println("There are " + tagCount +
         " <name> elements.");
    }//end of class Sink
    Before the end of this class i also need to make the array available to the calling program!!
    Any help would be much appreciated
    Thanks
    Iain

    Ok, yer going about this all the wrong way. You shouldn't have to maintain a count of all the elements. Basically you are locking yourself into the XML tags not only all being there but are assuming they are all in the same order. What you should do is in your characters() method, put all of the characters into a string buffer. Then, in endElement() (which you dont use btw, you should) you grab the information that is in the string buffer and store it into your Customer object depending on what the tagName is.
    Also, you should probably use a List to store all the Customer objects and not an single array, it's more dynamic and you arent locked into a set number of Customers.
    I wont do it all for you, but I'll give you a good outline to use.
    public class CustomerHandler extends DefaultHandler {
        private java.util.List customerList;  // List of Customer objects
        private java.util.StringBuffer buf;   // StringBuffer to store the string of characters between the start and end tags
        private Customer customer;  // Customer object that is initialized with each entry.
        public CustomerHandler() {
            customerList = new java.util.ArrayList();   // Initialize the List
            buf = new java.util.StringBuffer();   // Initialize the string buffer
        //  Make your customer list available to other classes
        public java.util.List getCustomerList() {
            return customerList;
        public void startElement(String nsURI, String sName, String tagName, Attributes attributes) throws SAXException {
            // Clear the String Buffer
            //  If the tagName is "Customer" then create a new Customer object
        public void characters(char[] ch, int start, int length) {
            //  append the characters into the string buffer
        public void endElement(String nsURI, String sName, String tagName) throws SAXException {
            // If the tagName is "Customer" add your customer object to the List
            // Place the data from the String Buffer into a String
            //  Depending on the tagName, call the appropriate set method on your customer object
    }

  • Can't parse XML data

    I'm receiving an XML document over a TCP socket, I then instantiate an instance of DOMParser and attempt to parse the data. Here's the exception:
    org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0x0) was found in markup after the end of the element content.
         at org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1213)
         at org.apache.xerces.framework.XMLDocumentScanner.reportFatalXMLError(XMLDocumentScanner.java:588)
         at org.apache.xerces.framework.XMLDocumentScanner$TrailingMiscDispatcher.dispatch(XMLDocumentScanner.java:1461)
         at org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:381)
         at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1098)
    Here's the relevant snippet(s) of source (there is code to write out the socket, but I didn't include that)
    Socket socket = new Socket( hostIP, hostPort );
    OutputStream outStream = socket.getOutputStream();
    InputStream inStream = socket.getInputStream();
    DataInputStream dataInStream = new DataInputStream( inStream );
    byte[] inByteArray  = new byte[ 2048 ];
    int length =  dataInStream.read( inByteArray );
    InputStream byteData  =  new ByteArrayInputStream( inByteArray );
    try
           DOMParser dp = new DOMParser();
           dp.parse( new InputSource( byteData ));
           Document doc = dp.getDocument();
    catch ( Exception e )
            e.printStackTrace();
            System.exit( 1 );
    }Is there a different way to do this? I even tried creating a new String based on the length read from the socket, minus one. The parser then saw that the final angle bracket of my root element was missing, so it doesn't seem to be an encoding issue.
    Any help would be appreciated.
    Jeff

    An invalid XML character (Unicode: 0x0)The XML is corrupt.
    ...saw that the final angle bracket of my rootelement was missing,
    After you subtracted one from the length - that would
    suggest that not subtracting one would be a good
    idea.Yep. That was a test to verify that the data was in tact and not null terminated. To doubly check, I took an Ethereal trace of the wire, and there was no null. If I convert the byte[] to a String, everything is fine. Unfortunately,
    there wasn't a parser method that took the XML document as a String.
    >
    I would suppose that the real problem here has
    nothing to do with XML nor DOM but rather that you
    are not correctly retreiving the data from the socket.Data is fine from the socket, I just had to implement my own getAttribute() and getElementContent, and use brute force. I just thought using an already written parser made more sense.
    Thanks for the reply.

  • How to parse xml data into java component

    hi
    everybody.
    i am new with XML, and i am trying to parse xml data into a java application.
    can anybody guide me how to do it.
    the following is my file.
    //MyLogin.java
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.util.*;
    class MyLogin extends JFrame implements ActionListener
         JFrame loginframe;
         JLabel labelname;
         JLabel labelpassword;
         JTextField textname;
         JPasswordField textpassword;
         JButton okbutton;
         String name = "";
         FileOutputStream out;
         PrintStream p;
         Date date;
         GregorianCalendar gcal;
         GridBagLayout gl;
         GridBagConstraints gbc;
         public MyLogin()
              loginframe = new JFrame("Login");
              gl = new GridBagLayout();
              gbc = new GridBagConstraints();
              labelname = new JLabel("User");
              labelpassword = new JLabel("Password");
              textname = new JTextField("",9);
              textpassword = new JPasswordField(5);
              okbutton = new JButton("OK");
              gbc.anchor = GridBagConstraints.NORTHWEST;
              gbc.gridx = 1;
              gbc.gridy = 5;
              gl.setConstraints(labelname,gbc);
              gbc.anchor = GridBagConstraints.NORTHWEST;
              gbc.gridx = 2;
              gbc.gridy = 5;
              gl.setConstraints(textname,gbc);
              gbc.anchor = GridBagConstraints.NORTHWEST;
              gbc.gridx = 1;
              gbc.gridy = 10;
              gl.setConstraints(labelpassword,gbc);
              gbc.anchor = GridBagConstraints.NORTHWEST;
              gbc.gridx = 2;
              gbc.gridy = 10;
              gl.setConstraints(textpassword,gbc);
              gbc.anchor = GridBagConstraints.NORTHWEST;
              gbc.gridx = 1;
              gbc.gridy = 15;
              gl.setConstraints(okbutton,gbc);
              Container contentpane = getContentPane();
              loginframe.setContentPane(contentpane);
              contentpane.setLayout(gl);
              contentpane.add(labelname);
              contentpane.add(labelpassword);
              contentpane.add(textname);
              contentpane.add(textpassword);
              contentpane.add(okbutton);
              okbutton.addActionListener(this);
              loginframe.setSize(300,300);
              loginframe.setVisible(true);
         public static void main(String a[])
              new MyLogin();
         public void reset()
              textname.setText("");
              textpassword.setText("");
         public void run()
              try
                   String text = textname.getText();
                   String blank="";
                   if(text.equals(blank))
                      System.out.println("First Enter a UserName");
                   else
                        if(text != blank)
                             date = new Date();
                             gcal = new GregorianCalendar();
                             gcal.setTime(date);
                             out = new FileOutputStream("log.txt",true);
                             p = new PrintStream( out );
                             name = textname.getText();
                             String entry = "UserName:- " + name + " Logged in:- " + gcal.get(Calendar.HOUR) + ":" + gcal.get(Calendar.MINUTE) + " Date:- " + gcal.get(Calendar.DATE) + "/" + gcal.get(Calendar.MONTH) + "/" + gcal.get(Calendar.YEAR);
                             p.println(entry);
                             System.out.println("Record Saved");
                             reset();
                             p.close();
              catch (IOException e)
                   System.err.println("Error writing to file");
         public void actionPerformed(ActionEvent ae)
              String str = ae.getActionCommand();
              if(str.equals("OK"))
                   run();
                   //loginframe.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    }

    hi, thanks for ur reply.
    i visited that url, i was able to know much about xml.
    so now my requirement is DOM.
    but i dont know how to code in my existing file.
    means i want to know what to link all my textfield to xml file.
    can u please help me out. i am confused.
    waiting for ur reply

  • Parsing the data from and xml type field

    Hi - I have registered a schema and inserted arecord into the table with the xml type column. Now I want to parse the data from the xmltype field into a relational table. I have been using the following select statement to accomplish this - and it does work if there is data in all the selected fields but when the filed is null then the whole select statement fails and brings back 'no rows returned'.If the value is null I want the select statment to return null. please give any ideas.
    SELECT version,frmd_transaction_date,extractValue(value(b), 'event_update/location')"location",
    extractValue(value(b), 'event_update/sending_system')"sending_system",
    extractValue(value(b), 'event_update/event_identifier')"event_identifier",
    extractValue(value(b), 'event_update/event_link')"event_link",
    extractValue(value(b), 'event_update/organization_code')"organization_code",
    nvl(extractValue(value(c), '/schedule/event_duration_minutes'),'000')"event_minutes"
    FROM fraamed_user.frmd_event_update , TABLE(xmlsequence(extract(xml_event_update, '/event_update')))b,
    TABLE(xmlsequence(extract(xml_event_update, '/event_update/schedule')))c

    ...then I guess you have to rewrite the query.
    Is schedule another xml sequence inside of event_update sequence ?
    If it is not you can try this :
    SELECT version,frmd_transaction_date,extractValue(value(b), '/event_update/location/text()')"location",
    extractValue(value(b), '/event_update/sending_system/text()')"sending_system",
    extractValue(value(b), '/event_update/event_identifier/text()')"event_identifier",
    extractValue(value(b), '/event_update/event_link/text()')"event_link",
    extractValue(value(b), '/event_update/organization_code/text()')"organization_code",
    extractValue(value(b), '/event_update/schedule/event_duration_minutes/text()')"event_minutes"
    FROM fraamed_user.frmd_event_update , TABLE(xmlsequence(extract(xml_event_update, '/event_update')))b
    ...if yes, did you try nvl function (I don't think this would be a solution of a problem):
    SELECT version,frmd_transaction_date,nvl(extractValue(value(b), '/event_update/location/text()')"location", 'NULL VALUE'),
    nvl(extractValue(value(b), '/event_update/sending_system/text()')"sending_system",'NULL VALUE'),
    nvl(extractValue(value(b), '/event_update/event_identifier/text()')"event_identifier",'NULL VALUE'),
    nvl(extractValue(value(b), '/event_update/event_link/text()')"event_link",'NULL VALUE'),
    nvl(extractValue(value(b), '/event_update/organization_code/text()')"organization_code",'NULL VALUE'),
    nvl(extractValue(value(c), '/schedule/event_duration_minutes/text()')"event_minutes",'NULL VALUE')
    FROM fraamed_user.frmd_event_update , TABLE(xmlsequence(extract(xml_event_update, '/event_update')))b,
    TABLE(xmlsequence(extract(xml_event_update, '/event_update/schedule')))c
    If none of this works post your xml schema.

  • Reading a file and parsing the data for a calculation method

    i am trying to read a file with 3 feilds double double and int . am able to read the file but i am getting an exception right befor i parse the data ...code
    import java.io.BufferedReader;
    import java.io.FileReader;
    import java.io.*;
    //import com.sun.java.util.jar.pack.Package.File;
    public class FileTester {
    public static String mLine;
         public static void main(String[] args) {
              BufferedReader in = null;
              try{
              File f = new File ("loan.txt.txt");
              in = new BufferedReader(new FileReader(f));
              catch(FileNotFoundException e)
                   System.out.println("file does not exist");
                   System.exit(0);
              try{
              String mLine = in.readLine();
              while (mLine != null){
                   System.out.println(mLine);
                   mLine = in.readLine();
              }}catch(Exception e)
              {System.out.println(e.getMessage());
              String []data = mLine.split("\t");
              double loan = Double.parseDouble(data[0]);
              double interest = Double.parseDouble(data[1]);
              int term = Integer.parseInt(data[2]);
              System.out.println(loan+interest+term);
    afterwards i would like to break this up into three methods to feed the values to a calculation class

    Take a look at your while loop. It continues to loop as long as mLine != null. Therefore it stops looping when mLine IS = null. So can you now see why the following line of code would cause problems?
    String []data = mLine.split("\t");How is the data stored in your file? Is it a single line with the three values separated by a tab? If so you can do away with the while loop and just call readLine() once. Otherwise you will have to process each line you read inside the while loop.
    P.S. use the code button when posting code. There is a button above the textfield when use post a reply.

  • Using Digital I/O to generate serial data stream

    Hello All,
    I am in need to generate a serial data stream. HW I use is MIO-16E-10.
    I am planning to use the digital line out to generate the serial data stream.
    I seems that if I use the wait timer the minimum pulse width I can get is
    1ms. But for my application the pulses have to be shorter than that. I was
    wondering about an alternative way to achive this. Any one who has worked
    with a similar application please help!
    Thanks in advance!
    Anand.

    Anand,
    What you are looking to do is not possible with the digital lines on the board you have.
    Depending on what other connections you have on the board, you could use one of the two analog outputs to generate your required serial data stream using pattern generation. Check the DAQ solution wizard=>Custom DAQ applications=>Analog Output=>Generate continuous sine wave. This example should give you a baseline to get started. Substitute the sine wave generator for your desired digital stream Logic 0 =0V, Logic 1=5V.
    If you need more than 2 lines, or some form of handshaking, I would suggest using the PCI-6534 or (DIO-32-HS as it was previously called) This will give you the ability to generate serial data streams with timing and/or handshaking.

  • How to parse system date to return Date and in yyyy-MM-dd format?

    DateFormat dateFormat = new SimpleDateFormat ("yyyy-MM-dd");
    java.util.Date date = new java.util.Date ();
    String dateStr = dateFormat.format (date);
    try{
    Date date2 = dateFormat.parse (dateStr);
    }catch(ParseException pe){
    pe.printStackTrace();
    Actually, After parsing the date from string, again it is converted into dfault format i.e. 21 Jan 00.00.00 etc...
    But I want this parsing date in yyyy-MM-dd format and again to return date.
    Can anybody tell me how to do this?

    DateFormat dateFormat = new SimpleDateFormat
    ("yyyy-MM-dd");
    java.util.Date date = new java.util.Date ();
    String dateStr = dateFormat.format (date);
    try{
    Date date2 = dateFormat.parse (dateStr);
    }catch(ParseException pe){
    pe.printStackTrace();
    Actually, After parsing the date from string, again
    it is converted into dfault format i.e. 21 Jan
    00.00.00 etc...
    But I want this parsing date in yyyy-MM-dd format and
    again to return date.
    Can anybody tell me how to do this?A Date object does not have a format, it represents a moment in time. You can use SimpleDateFormat to return a String representing that moment in time in many formats - this does not change the Date object to have that format (which it cannot since it does not contain a format).

  • How to parsing xml data in sql statement??

    Hi friends, I have a table which contain column as clob ,stores in xml format, for example my column contain xml data like this
    <Employees xmlns="http://TargetNamespace.com/read_emp">
       <C1>106</C1>
       <C2>Harish</C2>
       <C3>1998-05-12</C3>
       <C4>HR</C4>
       <C5>1600</C5>
       <C6>10</C6>
    </Employees>
      Then how to extract the data in above xml column data using SQL statement...

    Duplicate post
    How to parsing xml data in sql statement??

  • How to parse timestamp data

    Hi,
    I am not able to parse timestamp data. I am bringing this timestamp from AD through LDAP attribute through java code. I want date and time from this timestamp so that I can compare it with another date and time and get the difference between the two.
    If anybody knows the solution for this then please let me know.
    Thanks,
    Kalpana.

    Hi Kalpana,
    try this to convert AD date to java date format
         final long FILETIME_EPOCH_DIFF = 0xa9735dcc400L;
         final long HUNDRED_NANO_PER_MILLI_RATIO = 10000L;
         long activeDirDate = 129476773898586231L;
         long l1 = activeDirDate / 10000L;
         long l2 = l1 - FILETIME_EPOCH_DIFF;
         Date newdate = new Date(l2);
         System.out.println("AD Date is in Java Date format : "+newdate);
    Thanks,
    Pallavi

  • Parse a Date to String

    Hi
    i would use this to parse String to Date :
    public Date parseFromString(String dateString){
          try {
              java.text.SimpleDateFormat formatter
                  = new java.text.SimpleDateFormat("dd/MM/yy");
              return formatter.parse(dateString);
          catch (Exception e) {
          return null;
      }how can i parse a Date to string?
    Thanks
    D

    check the API Docs for SimpleDateFormat - particularly the format method. public StringFormatFromDate(Date date){
          try {
              java.text.SimpleDateFormat formatter
                  = new java.text.SimpleDateFormat("dd/MM/yy");
              return formatter.format(date);
          catch (Exception e) {
               // You really shouldn't catch Exception - and you really should do something in your catch
               // blocks so you don't post a question like "my code executes no problem, but nothing happens...
               e.printStackTrace();
          return null;
      }

Maybe you are looking for