JAXP DOM reading and writting issues

import org.xml.sax.*;
import org.w3c.dom.*;
import javax.xml.parsers.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import java.io.*;
public class Test
{   public static void main(String[] args) throws Exception
    {     DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        dbf.setIgnoringElementContentWhitespace(true);
     DocumentBuilder db = dbf.newDocumentBuilder();
     read(db, "xml_in.xml");
     create(db,"xml_out.xml");
    public static void read(DocumentBuilder db, String fileName)
    {     Document d = null;
     try
     {   d = db.parse(new File(fileName));
     }catch(IOException ex)
     {   ex.printStackTrace();
         return;
     }catch(SAXException ex)
     {   ex.printStackTrace();
         return;
     Node n = d.getDocumentElement();
     System.out.println("Name of the root element: " + n.getNodeName());
     NodeList nl = null;
     nl = d.getElementsByTagName("*");
     System.out.println("Number of element:" + nl.getLength());
     System.out.println();
     nl = d.getElementsByTagName("user");
     System.out.println("Length:" + nl.getLength());
     for(int i=0; i<nl.getLength(); i++)
     {   System.out.println("id: "+nl.item(i).getAttributes().getNamedItem("id").getNodeValue());
         System.out.println("name: "+nl.item(i).getFirstChild().getTextContent());
    public static void create(DocumentBuilder  db, String fileName) throws Exception
     Document d = db.newDocument();
     d.appendChild(d.createComment("This is comment"));
     Element ele_root = d.createElement("root");
     d.appendChild(ele_root);
     Element ele_temp;
     ele_temp = d.createElement("sub");
     ele_temp.setAttribute("id","1");
     ele_temp.appendChild(d.createTextNode("data"));
     ele_root.appendChild(ele_temp);
     ele_temp = d.createElement("sub");
     ele_temp.setAttribute("id","2");
     ele_root.appendChild(ele_temp);
     //adding node
     NodeList nl = d.getElementsByTagName("sub");
     Element ele_parent = (Element)nl.item(0).getParentNode();
     ele_temp = d.createElement("sub");
     ele_temp.setAttribute("id","3");
     ele_parent.appendChild(ele_temp);
     d.normalize();
     Transformer t = TransformerFactory.newInstance().newTransformer();
     //t.setOutputProperty(OutputKeys.METHOD, "test");
     t.transform(new DOMSource(d), new StreamResult(new File(fileName)));
}xml_in.xml
<?xml version = "1.0" ?>
<user-detail>
     <user     id = "1"><name>user1</name><age>10</age></user>
     <user     id = "2">
          <name>user2</name>
          <age>20</age>
     </user>
     <user     id = "3">
          <name>user3</name>
          <age>30</age>
     </user>
</user-detail>The result from read(db, "xml_in.xml"):
>
Name of the root element: user-detail
Number of element:10
Length:3
id: 1
name: user1
id: 2
name:
id: 3
name:
>
both name of id 2 and 3 are missing due to the spacing, how to remove the spacing to avoid this problem?
The result from create(db,"xml_out.xml"):
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!--This is comment--><root><sub id="1">data</sub><sub id="2"/><sub id="3"/></root>how to set it nicely as below?
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!--This is comment-->
<root>
     <sub id="1">data</sub>
     <sub id="2"/>
     <sub id="3"/>
</root>thanks~

Removing the whitespace is the wrong approach. Instead you should realize that the creators of that XML can put in whitespace wherever they feel like it, and more importantly, that the whitespace is also part of the document. In particular it forms text nodes which are children of the element in which they are located, just as element nodes are children.
So your strategy of assuming that the "name" element will be the first child of the "user" element is incorrect. When there is whitespace before the "name" element, that whitespace will be the first child. So your strategy should be to get the "name" element which is a child of the "user" element.
And by the way, calling the "normalize" method of the DOM won't do anything to affect that. As usual Ram manages to provide un-useful information.

Similar Messages

  • Satellite A300-146 - CD/DVD read and write issue

    I have Toshiba Satellite A300-146, Model no : PSAJ0E, 1GB RAM, Intel Dual core 1.87 processor, Mobile Intel(R) 965 chipset family
    I'm using windows7 RC version.
    My DVD recorder is not working properly.
    *1) Not reading 700 mb CD and not reading most DVDs.*
    Few months ago, It read sony DVDs, read all CDs and dint read some local DVDs. Now it is not reading sony DVD and and all the CDs I used. But reads local DVDs..
    *2) Some times it may write DVDs but most of the time its not writing DVDs. Nero 7 showing 100% but the DVD is not written anything.*
    I'm using Vista drivers for my Window 7 OS...
    3.Should I install windows 7 drivers..?
    4.Is there any specific drivers for DVD drive.?
    Experts or those who recovered from the same problem. Please Help me.
    thanks in advance.

    Hi
    Maybe your CD/DVD drive is getting faulty... What do you think?
    But before you think about a new drive you should remove the upper- and lowerfilters in registry. You can follow the workaround from Microsoft:
    http://support.microsoft.com/kb/314060
    Make also sure that the lens from CD/DVD drive is clean. You can use a microfiber cloth to clean it. This cloth doesnt scratch the lens.
    Check this!!!
    Last but not least there are no special drivers for CD/DVD drive. Its a part of Windows and cant be updated.

  • Read and write a .CSV file contains cirillic characters issue

    Hi guys,
    I am a developer of a web application project which uses Oracle Fusion Middleware technologies. We use JDeveloper 11.1.1.4.0 as development IDE.
    I have a requirement to get a .csv file from WLS to application running machine. I used a downloadActinLinsener in front end .jspx in order to do that.
    I use OpenCSV library to read and write .csv files.
    Here is my code for read and write the .csv file,
    public void dwdFile(FacesContext facesContext, OutputStream out) {
    System.out.println("started");
    String [] nextLine;
    try {
    FileInputStream fstream1 = new FileInputStream("Downloads/filetoberead.CSV");
    DataInputStream in = new DataInputStream(fstream1);
    BufferedReader br = new BufferedReader(new InputStreamReader(in,"UTF-8"));
    CSVReader reader = new CSVReader(br,'\n');
    //CSVReader reader = new CSVReader(new FileReader("Downloads/ACTIVITY_LOG_22-JAN-13.csv"),'\n');
    List<String> list=new ArrayList();
    while ((nextLine = reader.readNext()) != null) {
    if(nextLine !=null){
    for(String s:nextLine){
    list.add(s);
    System.out.println("list size ; "+list.size());
    OutputStreamWriter w = new OutputStreamWriter(out, "UTF-8");
    CSVWriter writer = new CSVWriter(w, ',','\u0000');
    for(int i=0;i<list.size();i++){
    System.out.println("list items"+list.get(i));
    String[] entries = list.get(i).split(",");
    writer.writeNext(entries);
    //System.out.println("list items : "+list.get(i));
    writer.close();
    } catch (IOException e) {
    e.printStackTrace();
    say the filetoberead.CSV contains following data,
    0,22012013,E,E,ASG,,O-0000,O,0000,100
    1,111211,LI,0,TABO,B,M002500003593,,,К /БЭ60072715/,КАРТЕНБАЙ
    2,07,Balance Free,3
    1,383708,LI,0,BDSC,B,НЭ63041374,,,Т /НЭ63041374/,ОТГОНБААТАР
    2,07,Balance Free,161
    It reads and writes the numbers and english characters correct. All cirillic characters it prints "?" as follows,
    0,22012013,E,E,ASG,,O-0000,O,0000,100
    1,111211,LI,0,TABO,B,M002500003593,,,? /??60072715/,?????????
    2,07,Balance Free,3
    1,383708,LI,0,BDSC,B,??63041374,,,? /??63041374/,???????????
    2,07,Balance Free,161
    can somone please help me to resolve this problem?
    Regards !
    Sameera

    Are you sure that the input file (e.g. "Downloads/filetoberead.CSV") is in UTF-8 character set? You can also check it using some text editor having a view in hex mode. If each Cyrillic character in your input file occupies a single byte (instead of two), then the file is not in UTF-8. Most probably it is in Cyrillic for Windows (CP1251).
    If this is the case, you should modify the line
    BufferedReader br = new BufferedReader(new InputStreamReader(in,"UTF-8"));toBufferedReader br = new BufferedReader(new InputStreamReader(in,"windows-1251"));Dimitar

  • Need help to read and write using UTF-16LE

    Hello,
    I am in need of yr help.
    In my application i am using UTF-16LE to export and import the data when i am doing immediate.
    And sometimes i need to do the import in an scheduled formate..i.e the export and imort will happend in the specified time.
    But in my application when i am doing scheduled import, they used the URL class to build the URL for that file and copy the data to one temp file to do the event later.
    The importing file is in UTF-16LE formate and i need to write the code for that encoding formate.
    The problem is when i am doing scheduled import i need to copy the data of the file into one temp place and they doing the import.
    When copying the data from one file to the temp i cant use the UTF-16LE encoding into the URL .And if i get the path from the URl and creating the reader and writer its giving the FileNotFound exception.
    Here is the excisting code,
    protected void copyFile(String rootURL, String fileName) {
    URL url = null;
    try {
    url = new URL(rootURL);
    } catch(java.net.MalformedURLException ex) {
    if(url != null) {
    BufferedWriter out = null;
    BufferedReader in = null;
    try {
    out = new BufferedWriter(new FileWriter(fileName));
    in = new BufferedReader(new InputStreamReader(url.openStream()));
    String line;
    do {
    line = in.readLine();
    if(line != null) {
    out.write(line, 0, line.length());
    out.newLine();
    } while(line != null);
    in.close();
    out.close();
    } catch(Exception ex) {
    Here String rootURL is the real file name from where i have to get the data and its UTF-16LE formate.And String fileName is the tem filename and it logical one.
    I think i tried to describe the problem.
    Plz anyone help me.
    Thanks in advance.

    Hello,
    thanks for yr reply...
    I did the as per yr words using StreamWriter but the problem is i need a temp file name to create writer to write into that.
    but its an logical one and its not in real so if i create Streamwriten in that its through FileNotFound exception.
    The only problem is the existing code build using URL and i can change all the lines and its very difficult because its vast amount of data.
    Is anyother way to solve this issue?
    Once again thanks..

  • How do I read and write to text files on a remote computer's hard drive

    I would like to read and write data to a text file on a remote computer. This is easily accomplished using one of the file functions such as "write characters to file.vi". If I am already connected to the remote computer, all I need to do is specify the path to the particular file and it will work fine.
    My problem is that I want to connect to the remote computer programatically within LabVIEW (I do not want to have to use the computer's OS to establish the connection. Is there a function that I can use to do this?
    Thomas D. Schaefer
    Wells Manufacturing Corp

    Yariv,
    You should really start a new thread with a new question like this, so that more people see it. Some people look primarily at threads that have no responses yet. Also, don't post the exact same question in multiple places. Or, if you must cross-post to some other forum, make sure to mention it in your question text.
    I'm happy to be a brick in your Western Wall, but I'm not sure what the main objective is here. Is the main problem really getting access to the "X bytes received in Y seconds at Z bytes/sec" string? Or is it accomplishing the file transfer? And what OS and LabVIEW version are you running?
    I think your problem is that you the LabVIEW System Exec command does not allow for the degree of interactivity that you need if you want to issue a sequence of commands to a command-line executable. However, under Windows XP (and, presumably, other Windows versions, though I can't check), you can tell the FTP executable to use commands from a textfile script by using the -s switch, and you can override the prompts during multiple file transfers with the -i switch:
    ftp -i -s:FILEPATH SERVERNAME
    If you issue a command in this format to System Exec, and make sure to create a file at FILEPATH with your command sequence (one per line), then you should at least accomplish the FTP actions. This won't give you the transfer details in the standard output, unfortunately. However, if you just want a general sense of how much was transferred and how quickly it happened, you can code that in LabVIEW by getting the resulting file sizes and using Tick Count before and after the System Exec call to see how long the transfer took.
    Hope that helps,
    John

  • Plugin-container and Flashplugin are both generating a million reads and writes an hour... even when Firefox is minimized and running no audio/video; how can I

    I am running FF 18.0.2 on a Win7 system with an i7 CPU and 8GB RAM. My Flash plugin is newly-updated. I've used Firefox on this machine its entire life (3 years).
    Since 3 or 4 (?) versions ago, I've been getting massive activity on my hard drive with Firefox. When I check with Win Task Manager, I see the plugin-container.exe *32 and the FlashPlayerPlugin_11_5_502_149.exe *32 processes are generating millions of I/O reads and writes, even while Firefox is idle (minimized, running no audio or video). On this latest version, 18.0.2, the drive activity stalls out YouTube videos repeatedly, even though I can see they're buffered ahead. The playing video will stop, audio will continue to end of buffer, and then EVERYTHING stops (Firefox not responding) for 30 seconds or so. It will then pickup again and play until it repeats the same pattern in a minute or so.
    Example: I closed and restarted Firefox 2 days ago. Earlier today I checked Windows Task Manager and found the two processes EACH generated about 161 million reads and 141 million writes since then! My wife's laptop is showing nothing like a hundredth of that.
    The constant drive activity is slowing down all programs outside of Firefox too, as you might imagine. The PC is acting like it's a dedicated machine for Flash.

    The Reset Firefox feature can fix many issues by restoring Firefox to its factory default state while saving your essential information.
    Note: ''This will cause you to lose any Extensions, Open websites, and some Preferences.''
    To Reset Firefox do the following:
    #Go to Firefox > Help > Troubleshooting Information.
    #Click the "Reset Firefox" button.
    #Firefox will close and reset. After Firefox is done, it will show a window with the information that is imported. Click Finish.
    #Firefox will open with all factory defaults applied.
    Further information can be found in the [[Reset Firefox – easily fix most problems]] article.
    Did this fix your problems? Please report back to us!

  • Best Practice to Atomic Read and Write a Field In Database

    I am from Java Desktop Application background. May I know what is the best practice in J2EE, to atomic read and write a field in database. Currently, here is what I did
    // In Servlet.
    synchronized(private_static_final_object)
        int counter = read_counter_from_database();
        counter++;
        write_counter_back_to_database(counter);
    }However, I suspect the above method will work all the time.
    As my observation is that, if I have several web request at the same time, I am executing code within single instance of servlet, using different thread. The above method shall work, as different thread web request, are all referring to same "private_static_final_object"
    However, my guess is "single instance of servlet" is not guarantee. As after some time span, the previous instance of servlet may destroy, with another new instance of servlet being created.
    I also came across [http://code.google.com/appengine/docs/java/datastore/transactions.html|http://code.google.com/appengine/docs/java/datastore/transactions.html] in JDO. I am not sure whether they are going to solve the problem.
    // In Servlet.
    Transaction tx = pm.currentTransaction();
    tx.begin();
        int counter = read_counter_from_database();  // Line 1
        counter++;                                                  // Line 2
        write_counter_back_to_database(counter);    // Line 3
    tx.commit();Is the code guarantee only when Thread A finish execute Line 1 till Line 3 atomically, only Thread B can continue to execute Line 1 till Line 3 atomically?
    As I do not wish the following situation happen.
    (1) Thread A read counter from Database as 0
    (2) Thread A increment counter to 1
    (3) Thread B read counter from Database as 0
    (4) Thread A write counter as 1 to database
    (5) Thread B increment counter to 1
    (6) Thread B write counter as 1 to database
    What I wish is
    (1) Thread A read counter from Database as 0
    (2) Thread A increment counter to 1
    (4) Thread A write counter as 1 to database
    (3) Thread B read counter from Database as 1
    (5) Thread B increment counter to 2
    (6) Thread B write counter as 2 to database
    Thanks you.
    Edited by: yccheok on Oct 27, 2009 8:39 PM

    This is my understanding of the issue (you should research it further on you own to get a better understanding):
    I suggest you use local variables (ie, defined within a function), and keep away from static variables. Those local variables are thread safe. If you call functions within functions, its still thread safe. If you read or write to one record in a database using sql, its thread safe (you dont need a transaction). If you read/write to multiple tables and/or records, you probably need a transaction. Servlets are thread safe. You usually dont need the 'synchronized' word anywhere unless you have a function updating/reading a static variable and therefore want to ensure only one user is accessing the static varible at a time. Also do so if you are writing to some resource (such as a file, a variable in applicaton scope, session scope, or resource that everyone uses such as email server). You dont want more than one person at a time to write to it). Note the database is one of of those resources that is handled by transactions rather than the the synchronized keyword (the synchronized keyword is applied to your application only (not other applications that someone is running), whereas the transaction ensures all applications are locked out while you update those records in the database).
    By the way, if you have a static variable, you should have one and only one function (synchronized) that updates it that everyone uses. If you have more than one synchronized function, that updates it, its probably not thread safe.
    An example of a static variable you would use is a Datasource object (to obtain your database connections). You only need one connection pool in your application and you access it via the datasource variable.
    If you're unsure your code is thread safe, you can create two seperate threads that call the same block of functions repeatedly to ensure it works as expected.

  • Windows 2008 R2 Folder assign permission "Read and Write" problem with *.doc file

    Hello All,
    I am a new one here,
    I am sorry for any mistakes and also my english is so poor.
    M Brother company runing Windows 2008 R2 as Active Directory...
    We have folder Name: Admin
    and in this folder, there are alot documents files as : *.doc, *.dwg, *.txt etc.....
    All user accesing to these files and they can open to edit and save...
    One day my brother want me to set Admin folder for all users just"Read and Write.." mean they still can open files to edit and save... but can't delete..
    I did success with this..
    But only one thing happen.. when they open *.doc file to edit and attempting to save, the message alert" access denide " and they can only "SAVE AS"...We don't want "Save as"
    Could you show me how can we fix error with *.doc file while they trying to save? because it allow only save as.. but other files as *.text file or *.dwg they can save without problem..
    Could expert here ever face this issues and fix by yourself, please share me with this..
    Please help me..
    Best regards,

    Hi,
    Office programs are specific. They will create a temp file when edit, then the temp file will be deleted when close. So Delete permission is needed for users to saving Office files like Excel/Word.
    For more detaile information, please refer to the thread below:
    Special Permissions - User cannot save files
    http://social.technet.microsoft.com/Forums/windowsserver/en-US/721fb2f1-205b-46e5-a3dc-3029e5df9b5b/special-permissions-user-cannot-save-files
    Best Regards,
    Mandy 
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected]

  • How to burn read and write files on DVD

    I would like to know how to burn DVDs (image files) with the Read and Write setting. I have changed the settings in Get Info for the image files to Read and Write for Owner, Group and Others and yet when I burn the DVD and try and copy the files back onto the hard drive (to test if it works or not) it won't allow me. When I check the Get Info it says Read and Write for owner (greyed out) and Read Only for Group and Others (greyed out too).
    I have also tried to change the status of the blank DVD before adding files and after adding the files (but b4 the burn) to Read and Write, this works but then during the burn process the DVD or burner changes my settings to Read Only.
    I am burning with Finder and have tried with Toast 10 Titanium. What am I doing wrong, or not doing at all?! I'm going loopy with frustration!

    Kiraly, I agree that the actual problem here might be something else, but as a side issue there seems to be a difference in the way permissions are handled when a file copy is made using Finder compared to when the copy is made using the cp copy in Terminal. At least in my Tiger system, Finder preserved the permission structure, though not the ownership, when it copied a file, whereas cp used the OS defaults.
    I tried the following experiment:
    From my test user account "t", I created a textfile named ReadWrite.txt, and gave it Read+Write permissions for Owner, Group, and Others. I then burned it using Finder to a DVD which I named PermissionTest, and then unchecked the "Ignore Ownership" box on PermissionTest.
    The original ownership and permissions were preserved on the DVD, though of course you couldn't actually write to anything there:
    xxG5-Computer:~ t$ ls -l /Volumes/PermissionTest/ReadWrite.txt
    -rw-rw-rw- 1 t t 15 Sep 13 18:25 /Volumes/PermissionTest/ReadWrite.txt
    I then copied the file from the DVD to the Desktop using Finder, and the permissions were preserved!
    Finder copy:
    xxG5-Computer:~ t$ ls -l /Users/t/Desktop/ReadWrite.txt
    -rw-rw-rw- 1 t t 15 Sep 13 18:25 /Users/t/Desktop/ReadWrite.txt
    I then trashed the Finder copy of ReadWrite,txt on the desktop, and made a second copy from the DVD, but this time I used the cp command from Terminal instead of using Finder. This time the permissions were not preserved, but reverted to the OS default:
    cp copy:
    xxG5-Computer:~ t$ cp /Volumes/PermissionTest/ReadWrite.txt Desktop
    xxG5-Computer:~ t$ ls -l /Users/t/Desktop/ReadWrite.txt
    -rw-r--r-- 1 t t 15 Sep 13 19:43 /Users/t/Desktop/ReadWrite.txt
    I then switched to a different user account "t1", and repeated the above with the same DVD, first copying the ReadWrite.txt file to the desktop using Finder, and then using cp. The ownership of the copied file changed from t to t1 in both cases, but the permission structure again was preserved in the Finder copy but not in the cp copy:
    DVD file:
    xxG5-Computer:~ t1$ ls -l /Volumes/PermissionTest/ReadWrite.txt
    -rw-rw-rw- 1 t t 15 Sep 13 18:25 /Volumes/PermissionTest/ReadWrite.txt
    Finder copy:
    xxG5-Computer:~ t1$ ls -l /Users/t1/Desktop/ReadWrite.txt
    -rw-rw-rw- 1 t1 t1 15 Sep 13 18:25 /Users/t1/Desktop/ReadWrite.txt
    cp copy:
    xxG5-Computer:~ t1$ cp /Volumes/PermissionTest/ReadWrite.txt Desktop
    xxG5-Computer:~ t1$ ls -l /Users/t1/Desktop/ReadWrite.txt
    -rw-r--r-- 1 t1 t1 15 Sep 13 19:51 /Users/t1/Desktop/ReadWrite.txt
    I got similar results when I tried copying a file with Read+Write permissions for all from a USB flash drive to the Desktop, again with the "Ignore Ownership" box unchecked.

  • Read and write from access

    I am arun, a beginner in the field of LabVIEW. Now I am trying to read and write data from MS Access with out database connection toolset. How this possible. How I can use activex in Labview for doing this. Please give me some reference materials.

    Hi Arun,
    The following discussion forum talks about the same issue, and provides a good explanation and references for the different options. Also, which version of LabVIEW are you using?
    How to read/write from Access database
    Thanks,
    Lesley Y.

  • Urgent: Please help. how to solve the time delay during buffer read and write using vc++

    I need to continuously acquire data from daqmx card, write into a file and at the same time corelate (in terms of time) the data with signals from other instruments. The current problem is that there is time delay during read and write data into buffer,thus causing misalignment of the data from multiple instruments. Is there a way to solve  the delay? or Is there a way to mark the time of the data acquisition in the buffer?  If I know the starting time (e.g. 0) of data acquisition and sampling rate (e.g. 1kHz), can I simply add 1ms to each data sample in the buffer? The current code is shown below.
    void DataCollectionWin::ConnectDAQ()
    DAQmxErrChk(DAQmxCreateTask ("", &taskHandle));
        DAQmxErrChk(DAQmxCreateAIVoltageChan(taskHandle,"Dev1/ai0,Dev1/ai1,Dev1/ai2,Dev1/ai3,Dev1/ai4,Dev1/ai5,Dev1/ai16,Dev1/ai17,Dev1/ai18,Dev1/ai19,Dev1/ai20,Dev1/ai21,Dev1/ai6,Dev1/ai7,Dev1/ai22","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL));
      DAQmxErrChk(DAQmxCfgSampClkTiming(taskHandle,"",1000.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,60000));
      DAQmxErrChk (DAQmxRegisterEveryNSamplesEvent(taskHandle,DAQmx_Val_Acquired_Into_Buffer,50,0,EveryNCallback,NULL));// Every 50 samples the EveryNSamplesEvent will be trigured, to reduce time delay.
      DAQmxErrChk (DAQmxRegisterDoneEvent(taskHandle,0,DoneCallback,NULL));
      DAQmxErrChk (DAQmxStartTask(taskHandle));
    int32 CVICALLBACK EveryNCallback(TaskHandle taskHandle, int32 everyNsamplesEventType, uInt32 nSamples, void *callbackData)
     DAQmxErrChk (DAQmxReadAnalogF64(taskHandle,50,10.0,DAQmx_Val_GroupByScanNumber,data,50*15,&read,NULL));
       //memcpy(l_data,data,6000);
      SetEvent(hEvent);
    l_usstatus_e[0]=g_usstatus[0];// signals from other instruments that need to be corelated with the data from daq cards.
     l_optstatus_e[0]=g_optstatus[0];
     if( read>0 ) // write data into file
       //indicator=1;
     for (i=0;i<read;i++)
     {  //fprintf(datafile,"%d\t",i);
      fprintf(datafile,"%c\t",l_usstatus_s[0]);
      fprintf(datafile,"%c\t",l_usstatus_e[0]);
            fprintf(datafile,"%c\t",l_optstatus_s[0]);
      fprintf(datafile,"%c\t",l_optstatus_e[0]);
              fprintf(datafile,"%.2f\t",data[15*i]);
     //   sprintf( pszTemp, "%f", data[6*i]);
     // pListCtrl->SetItemText(0, 2, pszTemp);
        //pWnd->m_trackinglist.SetItemText(0, 2, pszTemp);
         fprintf(datafile,"%.2f\t",data[15*i+1]);
         fprintf(datafile,"%.2f\t",data[15*i+2]);

    Hello kgy,
    It is a bit of a judgment call. You should just choose the board that you think has the most to do with your issue. For example, this issue was much more focused on setting up your data acquisition task than the Measurement Studio environment/tools, so the MultifunctionDAQ board would have been the best place for it. As for moving your post to another board, I do not believe that is possible.
    Regards,
    Dan King

  • Process using Webservice in Reader and Writer becomes slow while connecting processors

    Hi,
    I have a process that reads from a web service and writes to a web service. When I try to modify the code(after stopping the running process) by adding new processors or change the current connections, the connecting arrows take forever to connect and sometimes the director hangs for a long time. There is no issue in other processes where I read and write from staged data.
    How to overcome this isue?
    Appreciate the help!
    Regards,
    Ravi

    Hi Nick,
    Thanks for the advice. In the scenario where upgrade is not an option, is there any workaround to this issue?
    What I've found is if I strip the next processor of all its connections, then it gets connected to the previous processor pretty quick.
    EDQ hangs if the processor has other input/output connections and I try to connect it to another processor)
    P1>---<P2>    <P3 ---------- P2 to P3 connects fast as P3 is standalone
    P1>---<P2>    <P3>---<P4> ---------- In this case,  when I try to connect P2 to P3, it hangs forever.
    I've a complex process and just for adding a few processors in between, I will not be able to connect the rest of the processors all over.
    Regards,
    Ravi

  • Read and Write iDVD trouble with backed up iDVD project

    Hey guys, I need to open an iDVD project file within my time machine backups for a previously existing user on an external backup hard drive.
    When I click it to open I get this message: "An error occurred while loading the project. This project seems to be write-protected and can't be opened."
    I've tried right clicking on the file, selecting 'Get info' and changing administrators and 'everyone' to read and write but no luck. Any ideas, suggestions would be greatly appreciated! Thanks!

    Correct.
    Now I see I missed the wording of the "file not writeable" message, which doesn't sound like a permissions issue. That sounds like it's either not compatible (ie, not for the same version of iDVD), or corrupted.
    If you haven't changed versions, try a +*Verify Disk+* on your internal HD, per #A5 in [Time Machine - Troubleshooting|http://web.me.com/pondini/Time_Machine/Troubleshooting.html] (or use the link in *User Tips* at the top of this forum).

  • Unparsing a DOM tree and write XML to file

    Hi,
    I have created a DOM tree from scratch and would like to unparse the DOM tree and write the XML to a file, but how do I do that?
    Does anybody got code examples that do this?
    All help are very appreciated!
    /Daniel

    Thank you very much for the hint! Unfortunaly I still got problem to get it work though.
    I made a little piece of test code to try it but during the execution of the "Transformer.transform(source,result)" method I gets an "org.w3c.dom.DOMException".
    Does anybody see what that problem might be cause of by exmining the code below?
    I also would like to know how to specify the location where I would like to print out the XML file.
    Here is my little piece of test code:
    try{
    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFadctory.newInstance();
    DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
    Document doc = docBuilder.newDocument();
    doc.appendChild(doc.createElement("topLevel"));
    Element elm = doc.getDocumentElement();
    elm = (Element)elm.appendChild(doc.createElement("PersonData"));
    elm = (Element)elm.appendChild(doc.createElement("Name"));
    elm.setAttribute("Firstname","D");
    elm.setAttribute("Lastname", "D");
    DOMResult result = new DOMResult(doc);
    DOMSource source = new DOMSource(doc);
    TransformerFactory transformerFactory = TansformerFactory.newInstance();
    Transformer transformer = transformerFactory.newTransformer();
    transformer.transform(source,result);
    }catch(ParserConfigurationException e) {
    }catch(IOException e) {
    }catch(TransformerException te) {

  • Fast, small-byte reads and writes.

    I am trying to communicate with a third-party counter using a 1 byte "start" command followed by reading a 4 byte number.  I would like to perform this read/write pair as fast as possible as I will be using count-times on the order of microseconds repeated millions of times.  Our first attempt used USB but the latency in the bus was way too slow at 1ms.  We spent more time waiting than counting. We are currently considering GPIB since the latency should be only 30 microseconds but we're concerned that the overhead from labview will prevent us from reading and writing that fast.  Another idea we had was to use digital I/O channels to create our own parallel port to by-pass the USB bus.  Can anyone comment on a good solution for low-latency small-byte reads and writes from labview? What type of hardware is recommended and can labview support programmatic reads-writes on the order of microseconds? Thanks!

    Theoretically GPIB is capable of very good latencies, as you say on the order of usec.  But in the real world using real PCs running real operating systems and connected to real instruments, the latencies seem to cluster around 2-5msec, in my experience.  The issue isn't LabVIEW so much as all the stuff through which instrumentation interactions must filter, including background processes, screen updates and all the rest of the activities which consume the processor's bandwidth.  Some instruments allow you to buffer and interpret the next command while the current one is underway, then trigger it, which saves latency.  Also keep in mind that your GPIB network will only be as responsive as the least-well-behaved instrument on the bus.

Maybe you are looking for