|
hi there,
i'm trying to write to xml doc. from a string which is assigned to parsed information from the web by using(regex):
string myString, myString2;
XmlTextWriter writer = new XmlTextWriter("data.xml", null);
writer.WriteStartDocument();
//Use automatic indentation for readability.
writer.Formatting = Formatting.Indented;
//Write the root element
writer.WriteStartElement("Schedule");
foreach(Match m3 in Regex.Matches(getPage, tm.ToString()))
{
Group g3 = m3.Groups[1];
Console.WriteLine(g3.ToString());
myString = g3.ToString();
//add sub-elements
writer.WriteElementString("Time", myString);
foreach(Match m3a in Regex.Matches(getPage, prog.ToString()))
{
Group g3a = m3a.Groups[1];
Console.WriteLine(g3a.ToString());
myString2 = g3a.ToString();
// //End the item element
// writer.WriteEndElement(); // end Rate
//add sub-elements
writer.WriteElementString("Programme", myString2);
//End the item element
writer.WriteEndElement(); // end Rate
}
}
// end the root element
//writer.WriteFullEndElement();
//Write the XML to file and close the writer
writer.Flush();
writer.Close();
}
i get this :05:00
Morning Reports
Wake Up to Money
Unhandled Exception: System.InvalidOperationException: Token StartElement in sta
te Epilog would result in an invalid XML document.
at System.Xml.XmlTextWriter.AutoComplete(Token token)
at System.Xml.XmlTextWriter.WriteStartElement(String prefix, String localName
, String ns)
at System.Xml.XmlWriter.WriteElementString(String localName, String ns, Strin
g value)
at System.Xml.XmlWriter.WriteElementString(String localName, String value)
at Scrape2.Scrape2.Main(String[] args) in c:\uni stuff\project stuff\scrape2\
scrape2.cs:line 83
any help plzz....
|
|
|
|
|
i actually need to alternate between the two foreach loops, i.e.
time
programme
time
programme
.
.
.
etc
|
|
|
|
|
How can I create the Thumbnail view from the form?
In the following approach we tried but we are facing some limitations to get the thumbnail image of the form alone.
Can anuy one please help how to creat the thumbnail of the form alone.
thanks!
Approach - I - Bitmap (screen capture method)
=============================================
Can able to create the thumbnail image using Bitmap and BitBlt.
Code Sample:
Graphics g1 = this.CreateGraphics();
Image MyImage = new Bitmap(this.ClientRectangle.Width,this.ClientRectangle.Height, g1);
Graphics g2 = Graphics.FromImage(MyImage);
IntPtr dc1 = g1.GetHdc();
IntPtr dc2 = g2.GetHdc();
BitBlt(dc2, 0, 0, this.ClientRectangle.Width, this.ClientRectangle.Height, dc1, 0, 0, 13369376);
g1.ReleaseHdc(dc1);
g2.ReleaseHdc(dc2);
MyImage.Save(@"c:\BaluCaptured.jpg", ImageFormat.Jpeg);
MessageBox.Show("Finished Saving Image");
Limitations Facing:
1) Not able to capture the non visible portion of the form.
2) If the specified region size is beyond the visible portion in the screen, then remaining portions are in black color.
Approach - II - Metafile
Can able create the image using Metafile approach. How can we create the metafile for user controls drawn objects (Example: Graphs, Gauges).
Graphics grph = this.CreateGraphics();
IntPtr ipHDC = grph.GetHdc();
Metafile mf = new Metafile(@"d:\TestBalu.emf", ipHDC, EmfType.EmfPlusDual);
//grph.ReleaseHdc(ipHDC);
//grph.Dispose();
grph = Graphics.FromImage(mf);
grph.DrawRectangle(Pens.Blue, 10, 10, 100, 120);
Point p1 =new Point(20,60);
Point p2 =new Point(40,80);
Point p3 =new Point(100,120);
Point p4 =new Point(120,260);
Rectangle re=new Rectangle(30,20,60,90);
grph.DrawBezier(Pens.Gold, p1,p4,p3,p2);
grph.DrawBezier(Pens.Gold, p2,p4,p3,p2);
grph.Dispose();
Limitations Facing:
1) This can be possible for regular Graphics objects like creating Rectangle, Ellipse... using System.Drawing class.
2) It is not supporting for 3rd Party controls like Dundas gauge controls.
When we try to create the metafile (emf) the file size shows 0KB. It is not writing the data in to the file.
Approach – III – Scale down the Form
How to clone the form which contains the graphics objects like rectangle, user controls?
When we are trying to clone, it is only referring the memory; it is not actually cloning the object.
Code Sample:
Form2 obj = new Form2();
obj.Width = 640;
obj.Height = 480;
obj.BackColor = Color.Green;
obj.Show();
Form obj1 = new Form2();
obj1 = obj;
obj1.MaximizeBox = false;
obj1.MinimizeBox = false;
obj1.ControlBox = false;
obj1.FormBorderStyle = FormBorderStyle.None;
obj1.Scale(0.2f, 0.2f);
obj1.Show();
Limitations Facing:
==================
In .net we don’t have direct clone method to clone the form object. How can we clone the form object?
Even we tried with IClonable Interface's clone method also. Can any body please explain the clone() implementation in detail?
Thanks,
With Regards,
Balu Ramachandran
|
|
|
|
|
Hi all
Does any one know? how can we dynamically design a Tree (Data Structure) by using two or more label’s to hold the corresponding node information.
For example Display should look like this
Label A (root node)
|
----------------------------------------------
| |
Label B (child node) Label C (child node)
|
|
(so on............)
Please help me how can I draw an Tree Data Structure in C# .net
For a web application. The Label’s are dynamically created programmatically.
Thank you
|
|
|
|
|
Hi..,
Does any body have know about querys of take backup and restore of db with paraments like user name, password, connection?
Does any body no how export and import data to Access or any other db format with the same paraments as above?
Please help i am using C#.Net in programming.
|
|
|
|
|
Hi All,
From the application we are waiting, Process.WaitForExit() , for the installation to get over and once over with the installation, does some actions. But in some installations the parent/main process just instantiate the child process and get kill. And child process does the installation and get kill once installation is over. So in my appliation's code.
* I start the installation
* Store the main process id and wait for exit.
* Once parent/main process get kill.
* From the task manager list I check all the process whose parent id is equivalent to the one I stored.
* If any child process exist then again wait for exit.
* Once all the child process get kill then contiune with some actions.
But with some installations the child process still remain active even though the installation is over. So in this case I won't be able to continue..
If anyone has solutions to the above problem then please let me know.
Thanks & Regards,
Shiby Chacko.
|
|
|
|
|
What kind of installations is this? Installations of other programs that are out of your control?
Is it certain installation packages that doesn't work, or is the success depending on something else?
|
|
|
|
|
First thanks for your response.
From my application, I install some other package that are out of my control. Every installers behaviour is not the same. e.g
Case I with editplus installer
1 From my application I start the editplus installation
2 Store the main process id and wait for exit.
3 Once parent/main process get kill.
4 From the task manager list I check all the process whose parent id is equivalent to the one I stored.
5 If any child process exist then again wait for exit. (Now in this case there is no child process created. Goto step 7. )
6 Once all the child process get kill then contiune with some actions.
7 Continue with rest of the action
Case II with Photoshop
1 From my application I start the Photoshop installation
2 Store the main process id and wait for exit.
3 Once parent/main process get kill.
4 From the task manager list I check all the process whose parent id is equivalent to the one I stored.
5 If any child process exist then again wait for exit. (Now in this case there are two child processes get created. Goto step 6. )
6 Once all the child process get kill then contiune with some actions.
7 Continue with rest of the action
Case III with winamp lite
1 From my application I start the winamp lite installation
2 Store the main process id and wait for exit.
3 Once parent/main process get kill.
4 From the task manager list I check all the process whose parent id is equivalent to the one I stored.
5 If any child process exist then again wait for exit. (Now in this case there are two child processes get created. Goto 6.)
6 Once all the child process get kill then contiune with some actions.(but in this case, one process remains active, so could not goto step 7.)
7 Continue with rest of the action
In the above case I could not go to step 7 because one installer process remains active. How do I know/get notify that the installation is done/complete.
Regards,
Shiby
|
|
|
|
|
Is it always the same installation(s) that goes wrong?
|
|
|
|
|
Yes, it is always the same installation(s) that goes wrong. But there could be some other installation(s) which can behave the same.
|
|
|
|
|
Hi all,
Anyone knows how to use Microsoft Office Pivot Table 9.0 component in asp.net(c#).
Help me
Prabhakar.A
Software Engineer
|
|
|
|
|
Hi,
I am in need of some help.I want to Use tree view in C# so that in can use it to show the various hard drives on my computer ( i.e. traverse my drives as in case of explorer ).So I ran across this software called
My Explorer In C# developed By Paul Li to be found at url:
http://www.codeproject.com/csharp/my_explorer.asp
I was trying to use it but could not much help about it. I would really appreciate if any one can help me out to figure it out how to make use of it or put as similar feature on my form.
Thanks.
Salman.
|
|
|
|
|
is it possible to get the name of the function that a delegate contains during runtime?
|
|
|
|
|
|
Hi,
I'm scanning some documents in using the example ".NET TWAIN image scanner" posted here in Code Project by NetMaster. I was able to get it working for what I needed, but there are times where I need to scan a blank page (i.e. scanning duplex and the last page is blank).
Since the TWAIN DLL is returning the document as a hbitmap, I'm converting this to an Image so I can save it off to different file types.
Is there a way for me to determine if the Image is a blank page (i.e. all one color or something)?
Thanks,
Robert Wandell
|
|
|
|
|
i think there is somemethod like this in the Color. structure
ByMindOnlyYouCanDoIt
|
|
|
|
|
A scanned image is seldom ever "blank" with a single color. There are always variations in the image, such as dust and smudges that won't be "blank". Try scanning a completely blank piece of paper and look at the image magnified. You'll find that a blank "white" page, even though it's completely clean, is not consistantly one color from pixel to pixel in the image.
Your going to have to come up with an algorithm to evaluate the scanned image and come up with an "overall" color value for the page. Then you compare that value to a "threashold" value that signifies that the page is blank, or just doesn't have enough ink on it to consider it "not blank".
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi, I'm totally new on this.
I have an ArrayList with several values
ArrayList itemList = new ArrayList();
itemList.Add("Blue hat", "2");
itemList.Add("White hat", "4");
itemList.Add("Red hat", "1");
I'd like:
1) convert it to a string that look like this:
Blue hat - 2
White hat - 4
Red hat - 1
so I can load it to a mail message
2) insert it in to a data table in my database with 2 fields: Item & Quantity
Can it be done using ArrayList or I have to use 2 dimensional array?
Greatly appreciate!!!!
|
|
|
|
|
You have quite a few options.
1. Pack both values into a string array and put that in the ArrayList. Like
<br />
itemList.Add(new string [] {"Blue Hat", "2"});<br />
itemList.Add(new string [] {"White Hat", "4"});<br />
2. Use two ArrayLists, one for the hat and one for the number. Like
<br />
ArrayList hatList = new ArrayList();<br />
ArrayList numberList = new ArrayList();<br />
<br />
hatList[0] = "Blue Hat";<br />
numberList[0] = "1";<br />
3. Use an associative collection, like a Hashtable. Like
<br />
Hashtable h = new Hashtable();<br />
h.Add("Blue Hat", 1);<br />
h.Add("White Hat", 4);<br />
...<br />
I'd suggest 3. In that case, you can easily print items like
<br />
foreach(string hat in h.Keys)<br />
{<br />
Console.WriteLine(hat + " - " + h[hat].ToString());<br />
}<br />
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
When working with the collections in C#, I often make a class for storing the values in the collection. A very brief example:
<br />
public class Hat<br />
{<br />
public string Description;<br />
public string Number;<br />
<br />
public Hat(string description, string number)<br />
{<br />
Description = description;<br />
Number = number;<br />
}<br />
<br />
public string FullDescription()<br />
{<br />
return(this.Description + " - " + this.Number);<br />
}<br />
}<br />
This is how you can work with the values:
<br />
ArrayList itemList = new ArrayList();<br />
itemList.Add(new Hat("Blue hat", "2"));<br />
itemList.Add(new Hat("White hat", "4"));<br />
itemList.Add(new Hat("Red hat", "1"));<br />
<br />
for(int i = 0; i < itemList.Count; i ++)<br />
{<br />
Console.WriteLine(((Hat)itemList[i]).FullDescription());<br />
}<br />
|
|
|
|
|
Hi,
I want to locate the listViewItem when the mouse drag(not move) on the
listViewItems in a listView. I try to locate which listViewItem the mouse is dragOver at and I use the listView.getItemAt(e.X,e.Y) in the dragOver handler, but it can't return the listViewItem located by the mouse(it can return the right x, y of the mouse location)?
Why ?
Many thanks
|
|
|
|
|
What is the best approach to modifying a very large XML file?
If I load the XML file into an XmlDocument its going to cause performance problems. XmlTextWriter is only useful for writing purposes and doesn't help with modification. I ran across an article on this topic but it is helpless: MSDN article on efficient techniques for modifying large xml files[^]
The XML file is not going to change very often. It is possible to rebuild the entire file for every change, but that still hurts.
I'm looking to switching to SQL implementation (MSDE or Firebird). Any last suggestions before I go ahead?
|
|
|
|
|
XML simply wasn't designed for this. If your going to be constantly modifying data in very large XML files, your better off dumping it into a SQL server. If you have to move the data elsewhere, you can always export back to an XML file for transit.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi all,
I am building a client/Server application in which I test how much data can I send over the wireless medium using UDP, without any losses. I am trying to implement it by changing the packet size on the client ranging from 150 to 1500 bytes.
Code sample of what I mentioned above:
private static int[] packetSizes=new int[7] {150,256,500,750,1000,1250,1500};
foreach ( int i in packetSizes ) {
Console.Write( "\t{0}", i ); {
byte[] alterSendBytes=new byte[i];
if(socListener.Connected){
// Sends a message to the host to which you have connected.
Console.WriteLine(remoteEndPoint.Address);
string sendBytes="Start of packet"+"\n"+
"DateTime:"+DateTime.Now+"\n"+
"Packet Size:"+ alterSendBytes.Length+"\n"+
"Protocol used: UDP with 802.11b/g"+"\n"+
"Form of Movement:"+"\n"+
"End of packet";
alterSendBytes=Encoding.ASCII.GetBytes(sendBytes.ToCharArray());
socListener.SendTo(alterSendBytes,alterSendBytes.Length,SocketFlags.None,remoteEP);
The problem I am faing now is I am not able to know whether the packet size is really increasing at the client, as I have used a bytebuffer of size only 400 at the server, but still I am receiving packets which are supposed to be of 1500 bytes at my client.
Is it because I am sending a fixed amount of data and the bytebuffer assigns itself only that much space? Or is my logic a very bad idea?
Waiting anxiously,
Sowmya Mulukutla,
UAB
|
|
|
|
|
|