|
Why not just have a case for the XmlNodeType.Attribute ? Your switch cases will be called appropriately so even if you were to just write-out the attribute, it will happen in between XmlNodeType.Element and XmlNodeType.Text or XmlNodeType.EndElement , if there are any attributes. What you have anyway will not work anyway. AttributeCount - 1 would be the index of the last attribute. Remember that indexes in the .NET FCL are 0-based.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hello,
Is there a way to sort an xml with xslt faster? Right now a file with 15 records takes about 9 seconds. A file with 60 records takes about 15 seconds. I probably won't have more then 60 records but a file with 1000 records takes about 2 minutes. 15 seconds is still a little to long i think, is it possible to make it faster?
Thx in advance
|
|
|
|
|
How is the sorting being done? Through code you wrote or through an for-each order-by?
RageInTheMachine9532
|
|
|
|
|
Hi,
i did it like this:
private void SortXml(string sortOrder, string sortString)
{
xml.Load(filePath);
string pad = "//session[@name='" + cboSessions.SelectedItem.ToString() + "']";
XmlNodeList selectedNode = xml.SelectNodes(pad);
string box = selectedNode.Item(0).OuterXml;
xml.LoadXml(box);
XmlTextWriter xmltw = new XmlTextWriter(hulpfilePath,new UTF8Encoding(false));
xml.WriteTo(xmltw);
xmltw.Close();
string xsl = "<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">"
+ "<xsl:template match=\"@*|node()\">"
+ "<xsl:copy>"
+ " <xsl:apply-templates select=\"@*|node()\">"
+ "<xsl:sort data-type=\"number\"" + " select=\""+ sortString +"\"" + " order=\"" + sortOrder + "\"" + "/>"
+ "</xsl:apply-templates>"
+ "</xsl:copy>"
+ "</xsl:template>"
+ "</xsl:stylesheet>";
XslTransform xslt = new XslTransform();
StringReader rdr = new StringReader(xsl);
xslt.Load(new XPathDocument(rdr), null,null);
xslt.Transform(hulpfilePath,hulpfilePath,null);
ds.Clear();
ds.ReadXml(hulpfilePath);
File.Delete(hulpfilePath);
}
|
|
|
|
|
Since your having an XSL stylesheet do the sorting for you, there isn't really a way to get a significant speed increase. The only thing I can think of trying is loading the XML document and writing the sort yourself, shuffling around nodes using you own sort algorithm. But I don't know if your going to get the kind of performance your looking for. You could only try it and see.
I haven't had the cause to sort an XML file myself. I usually just get the data I need and have the visual control sort it as needed.
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Nome
|
|
|
|
|
i did it like appelz did it
thx for the help
|
|
|
|
|
Hello,
I want to open a file for my program. I'm doing it with the openfiledialog but my file can also be on a server. How can i get that file then? Is it possible?
thx in advance
|
|
|
|
|
OpenFileDialog Op=new OpenFileDialog();
Op.ShowDialog();
System.Diagnostics.Process.Start(Op.FileName.ToString());
Sreejith S S Nair
|
|
|
|
|
It depends on how you can access that server. If you access the file through a UNC, the OpenFileDialog can do that and most classes in the .NET FCL can use UNC paths. If it's an HTTP path, the OpenFileDialog can reference the file if you have the HTTP server in your Network Locations "directory", but most classes that deal with files won't be able to access it. You'd have to use a WebClient or something to download it first.
One agnostics way would be to use a WebRequest to request the file using the file path. If it's a local or UNC file path, a FileWebRequest is returned. If it's an HTTP URL, an HttpWebRequest is returned.
Really, though - you don't need to care. WebRequest.GetResponse returns a WebResponse which you can use to "download" (copy to local) the file and then you can work on it however you want. The WebRequest /WebResponse classes are pluggable protocols, and you can find out more information about them in the .NET Framework SDK under the System.Net namespace.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
Hi,
I have a dll. I want to know the functions inside the dll. I don't have documentation about it. I there any way to know that.
Karteek
|
|
|
|
|
If it is an unmanaged DLL, I don't think there is anyway to find out. If it is managed, you can always decompile it - using, for example, the .net reflector[^]
|
|
|
|
|
You could use the Depends tool that comes with Visual Studio 6 to get the function names (possibly!), but not the parameters that those functions use. On top of that, without the documentation, there is no way your going to know what those functions are used for and how to properly use them.
RageInTheMachine9532
|
|
|
|
|
Hi!
I would like to show a progess-window while a hardware-reading process blocks the running threat.
I tried to intercommunicate with
ProcessStartInfo startInfo =
new processStartInfo("Animation.exe");
startInfo.FileName=@"c:\animation.exe";
startInfo.UseShellExecute=false;
startInfo.RedirectStandardInput=true;
Process Anima=Process.Start(startInfo);
...
Anima.StandardInput.WriteLine("1");
But how can I read the Standard Input in a WinForm?
Or am I on a bad track?
Thanks
Ariadne
|
|
|
|
|
First you have to redirect the StandardOutput:
startInfo.RedirectStandardOutput=true;
Then you can read the output stream just like any test file stream, for example:
String outText = Anima.StandardOuput.ReadToEnd();
RageInTheMachine9532
|
|
|
|
|
Dave thank you,
but that is not my question.
My Question: How do I write in Animation.exe (WinForms-App) to the standard output-stream?
|
|
|
|
|
That is what you asked...
But how can I read the Standard Input in a WinForm?
You can't read the StandardInput. It's a one way pipe for input TO the application you launched. You have to read the StandardOutput to see what the application wrote to the screen.
RageInTheMachine9532
|
|
|
|
|
Yes that's the point: I want change the animation from the parent app.
Ie:
MyApp -> (starts) -> Animation.exe (starts)
later
MyApp -> (command) -> Animation.exe (change picture)
later
MyApp -> (kill) -> Animation.exe (ends)
I tought, I can use a Standard IO-Pipe to command Animation.exe to change it's picture. But I do not know, how to receive the command in Animation.exe
|
|
|
|
|
???????????????????????????????????????????????
???????????????????????????????????????????????
???????????????????????????????????????????????
I take it Animation.exe is a commandline utility that runs in a CMD window? Correct?
If Animation.exe is a normal Windows app (GUI interface), then this won't work...
You can "talk" to Animation.exe through the Standard pipes. StandardInput is the keyboard stream into Animation.exe and StandardOutput is the console stream that the app uses to display text. If you redirect both of these streams in the ProcessStart class you used, you can read and write to the streams using .StardardInput.WriteLine() and .StandardOutput.ReadLine() on the process object that is returned. The catch is, if you redirect the streams, the user won't see anything except a blank console window. No text will be displayed and the window won't respond to the keyboard. Your app will have to send keyboard input using .WriteLine() just like the user would type at the keyboard. If the user has to type EXIT to get the app to quit, your app would have to do something like p.StandardInput.WriteLine("EXIT") to do the same.
RageInTheMachine9532
|
|
|
|
|
>>If Animation.exe is a normal Windows app (GUI interface), then this won't work...
<<
That's the point. But how to talk to Animation.exe?
|
|
|
|
|
Your up a creek without a paddle now...
Unless Animation.exe exposes a COM interface you can use...
You could use SendKeys to send key strokes to Animate.exe, but you'll find it's a problematic solution. Animation.exe must support keyboard shortcuts (like Alt-F for selecting the File menu) and the user CANNOT click ANYWHERE during the operation where you are posting keystrokes. The user can click on something or the system can open another window that snatches the input focus while your posting keystrokes and the target app is process them. If the focus changes, your keystrokes will end up going somewhere you didn't want them to.
Other than that, your options get exceedingly complicated.
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Nome
|
|
|
|
|
Other than that, your options get exceedingly complicated.
Ups!
Now I know, why I did not find any hints in the helpfiles.
Ok, then I go back and call my pictures with different args in several started processes.
Thank you Dave!
Ariadne
|
|
|
|
|
I have a doubt.in remoting if you want to pass an object(in binary format) .then how it goes to the remote machine and what exactly happens internally.and how the remote machine keep track of the object.
rgds
devkalyan
|
|
|
|
|
These kinds of questions are best answered in .NET Remoting books like "Microsoft .NET Remoting[^]" from MS Press and "Advanced .NET Remoting[^]" from Ingo Rammer.
There is a chain of sinks where the object gets serialized using a formatter (like a BinaryFormatter , then through any optional sinks to the transport sink (like that for a TcpChannel ) which sends it across the wire. The other side does things in the exact opposite order. Every sink - including the serialization and transport sinks - are extensible and can be changed. The .NET FCL provides two formatters - a BinaryFormatter and a SoapFormatter - and two visible channels - a TchChannel and an HttpChannel .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
any idea about runtime polymorphism.
Sreejith S S Nair
|
|
|
|