|
This is much less time and memory efficient than a simple for loop.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: This is much less time and memory efficient than a simple for loop.
But it's just one line of code. It has to be fast.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
|
Am getting the value of a node from my XML like this..
XmlDocument doc = new XmlDocument();
doc.Load(Application.StartupPath + "\\XMLfile.xml");
string xpath = "/Image/Crop/X";
XmlNode ReadX = doc.SelectSingleNode(xpath);
XmlNode X = ReadX.FirstChild.ParentNode;
XmlNodeReader nodeReader = new XmlNodeReader(X);
X = doc.ReadNode(nodeReader);
(Is this right? As I am new to .Net..I req u to check out and If am wrong.. kindly correct my mistake)
And if am right..
I want to use this X as an integer.. How do I do this...
I tried a method..But it throws an error that "Cannot implicitly convert type Int to system.xml.xmlnode"..tell me a way to retrieve the value of a node from my xml and to use in my further part of my program.. as an integer..
Thank You!
|
|
|
|
|
One of the nice benefits of the built in .NET xml serialization is that you can create an object decorated with attributes and then use the XML Serializer object to directly read all of the file with little or no word. I would like into it a bit.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
Thanks for the response Sir,my reqst is..
Suppose i declare an integer called XP and now i want to assign the value of X(from previous coding) with XP. How do i convert it?
|
|
|
|
|
Shan85 wrote: string xpath = "/Image/Crop/X";
Shan85 wrote: I want to use this X as an integer.. How do I do this...
The letter 'X' is not an integer.
Say your XML looks like this:
<Image><Crop><X>22</X></Crop></Image>
Then, and this is certainly not the only way, without accounting for possible errors:
XmlDocument doc = new XmlDocument();
doc.LoadXml("<Image><Crop><X>22</X></Crop></Image>");
XmlNode node = doc.SelectSingleNode("//Image/Crop/X");
int val = int.Parse(node.InnerText);
System.Diagnostics.Debug.WriteLine(string.Format("X+1 = {0}", val + 1));
led mike
|
|
|
|
|
Great Job Mr.Mike..
A single line of code is enough..Littl confused now.
Like.... int XP = somthing.Convert.toint32(X)
u said that x is not an integer,.. But i want to use this node value as an integer in my next part of my program.. is t possib?
|
|
|
|
|
Take a look at int.TryParse() and int.Parse();
Just because we can; does not mean we should.
|
|
|
|
|
Shan85 wrote: u said that x is not an integer,.. But i want to use this node value as an integer in my next part of my program.. is t possib?
You posted an XPath statement, we can't tell from that what your XML looks like. If you don't post a XML fragment with this 'X' node containing an integer value, we can't give you a specific code example for it. In my previous reply I posted an XML fragment to go with the code that obtains the value from it.
led mike
|
|
|
|
|
i got it Mike...Thanks..
Pls clear my next doubt..
I have retrieved the value from an XML file...
wen a button is clicked.. a new form opens with a text box..
i want the value of the XML node to be displayed in the text box...
say..CropX is the integer.. tbX is the name of the text box..
How can i do that.. When the form,is initialised, the text box should be initiated with the cropX value..
pls help me lik previous time Mike..Awaiting for ur reply
|
|
|
|
|
XmlNode node = doc.SelectSingleNode("//Image/Crop/X");
myTextBox.Text = node.InnerText;
led mike
|
|
|
|
|
Thank u Mike..
Got the answer yesterday itself..
But forgot to reply you..sorry..
And a big thanks..
|
|
|
|
|
Hi All,
I have a from with a textbox and a button. when the user clicks on the button, the value of the textbox wil save into sql server database table that has a column 'Varchar' type. bud if the text in the textbox has a 'sinqle quote', im getting a sql error.
How can i solve this issue?
Thanx.
|
|
|
|
|
|
try replacing single quote with two singlequotes:
TextBox1.Text.Replace("'","''")
but give a look at SQL Injections before
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
|
|
|
|
|
With a question mark
Comamnd Text = "SELECT * FROM someTable where someValue = @someValue"
Then add a parameter to the command object. It works surprisingly well, although I still prefer stored procedures.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
Yes, stored procs are the way to go, and then still use parameters in the Command object. This will prevent most types of SQL injection attacks, although second-level attacks may still work. It will allow you to have single quote marks in the parameter values.
|
|
|
|
|
Hi,
I want my user's to share their shopping cart.For example, if a user want he can copy his shopping cart link to his friend and his friend can buy the same products.
Any idea will be helpfull.
Thanks
|
|
|
|
|
And where exactly are you stuck?
|
|
|
|
|
Question is way too general. I can think of 20 ways to do that right off the top of my head, but only one of them is going to work for you.
This is a programming questions forum. Your question is not a question that can be fixed with code. You need an architecture solution. This is not something that anyone can help you with. Ultimately, you are going to have to design this system yourself.
When you get to the point where you have some code written and something is not working right and you've spent at least 3 hours trying to fix it yourself, then you can post a question, and be sure to include sample code, requirements, and a description of the things you tried that didn't work, so we don't go trying the same things again.
|
|
|
|
|
Hello everyone,
I am trying to do some printing. I have a custom richtextbox and a datagrid I am printing, but I am having some positioning issues. My custom richtextbox makes use of the Microsoft code recommended for printing rich text boxes(http://support.microsoft.com/kb/812425). My problem is that I have a datagrid with some information that I would like to print following the richtextbox and I am having a problem determining the current y position on the page once I am finished printing the richtextbox. Does anyone have any suggestions on how I can go about this?????? Please help??????
Thanks,
Kendal
|
|
|
|
|
Nevermind, found out how to do it. Thanks anyway!
|
|
|
|
|
Hi
I've got an C# .NET 2 app that uses toolstrips with 3d look. When you start the app, a splashscreen appears and then after 30 or so seconds, the main screen appears.
If you CTL/ALT/DEL lock the machine during the startup, when you unlock, the toolstrips have lost their 3d style and appear 'flat'.
Anyone seen this before/know of a resolution?
Thanks in advance
Rob
|
|
|
|
|
RobMaddison wrote: 30 or so seconds
Man... that's a lifetime!
RobMaddison wrote: toolstrips have lost their 3d style
Is the the 3D styling a custom job (i.e. bitmaps/jpegs et al)? Have you tried setting a breakpoint on the render method (I can't remember the event, I know there's an OnPaint somwehere or something)?
My apologies - I don't do much front end stuff.
But fortunately we have the nanny-state politicians who can step in to protect us poor stupid consumers, most of whom would not know a JVM from a frozen chicken. Bruce Pierson Because programming is an art, not a science. Marc Clifton
|
|
|
|