dcm2xml problem

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
christoff
Posts: 5
Joined: Mon, 2006-06-19, 19:24

dcm2xml problem

#1 Post by christoff »

Hello,

I have been developing an application that in one of it's processes uses the dcm2xml.exe utility to extract patient related information from a DICOMDIR file produced by eFilm 2.0. The application runs on the .Net framework, and I've come across a problem that I'm hoping someone here has the answer to.

The application calls the dcm2xml utility from a Process call during the label creation process. The process is supposed to run the dcm2xml utility and pull the resulting xml string back into the application to be parsed.

The problem that I am having is that when this application was a console application that ran on .Net 1.1, it ran fine. The xml would be pulled from the DICOMDIR file and I could parse the patient information that I needed. However, once I began porting the application over to a Windows form on .Net 2.0, the same script would no longer work.

I've posted the script below:

Code: Select all

//create process to run dcm2xml.exe to extract all data in xml format
            //set process parameters
            Process proc = new Process();
            proc.StartInfo.FileName = "dcm2xml.exe";
            proc.StartInfo.Arguments = "c:\\DICOMDIR";
            proc.StartInfo.UseShellExecute = false;
            proc.StartInfo.RedirectStandardOutput = true;
            proc.StartInfo.CreateNoWindow = true;
            proc.Start();
            StreamReader sr = proc.StandardOutput;
            //load xml data into a xmlDocument object for parsing
            XmlDocument xmldoc = new XmlDocument();
            xmldoc.LoadXml(sr.ReadToEnd());
I have confirmed that the xml is indeed extracted by adding an xml filename parameter to the arguments call, which results in a full extraction of data from DICOMDIR. However, the streamreader just returns an empty string without the xml filename parameter included.

I would appreciate any advice, as this problem is very perplexing.

christoff
Posts: 5
Joined: Mon, 2006-06-19, 19:24

#2 Post by christoff »

Update with some more info:

The exception message gives a "Root element is missing" error. However, I have checked and rechecked, and the xml is being exported when I have it write to file. The only time I am unable to access the data is when I try to pull it back into my application.

The exported xml can be viewed [link outdated and removed]. I would have pasted it, but it is a rather large xml string and I didn't want to clutter up the page. All actual value data has been removed from the xml to protect privacy, but all of the elements and their attributes are still in place. I would really appreciate any assistance on this, as I cannot see why this script does not work any longer.

I have also tried using a string value and filling it with the [Process].StandardOutput.ReadToEnd() method, which should work in a similar manner to the code I am already using. This code fails as well, with the same result.

The one thing that does work is writing the xml to file, then loading it into my application via the written xml file. Although this is functional, it seems like a lame workaround to something that should be working already. I suppose if I can't figure it out, I'll have to do it this way, but I would really prefer to have my code be as efficient as possible (at least, as effecient as a rookie like me can write it).

Thanks again in advance to anyone that can provide help or advice.

Christoff
NESG

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest