|
I have a program has a few things that it gets from online that i want to use. I'm not sure if it puts it together itself, or if it simply downloads one site, changed based on the search. Is there a program that could tell me eveything that my computer downloads?
|
|
|
|
|
hi
here is the scenario.. When the user selects a Title from the list box the related info for that title is shown in the browser control.. As I am searching with the expr="rss/channel/item/title" -> this will get all titles from the xml document and the condition in the loop will check for the selected title, To show the related info for the title...such as link and description..
How can I access these elements(link and description)? one method is Nodes.Item(i).NextSibling but with this method I can't gaurentee the next element will be link or description ! So I have to navigate all the elements in the selected Node Right? How can I do that...
[CODE]
string expr="rss/channel/item/title";
XmlDocument d= new XmlDocument();
d.Load(path);
XmlNodeList Nodes =d.SelectNodes(expr);
for(int i=0;i<nodes.count;i++)
{
="" if(nodes.item(i).innertext="=s)
" get="" other="" elements=""
="" }
="" }
[="" code]=""
<div="" class="ForumSig">Q@!$3r
|
|
|
|
|
You're using selectnodes to find your node set, you can use it again on the nodes you find, to find subnodes. Or, SelectSingleNode, if you know there is no more than one.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Rizawn wrote: How can I access these elements(link and description)?
It would be helpful to see your XML in order to tell you exactly how, but maybe you already figured this out with Christian's suggestions.
One annotation for the code you already got. Why don't you incorporate the title from the list box into the XPath expression? This way you would not need to check yourself and can simply iterate over the returned node collection. From the top of my head and should be:
string expr="rss/channel/item/title[text()=" + s + "]";
Note that I assume s contains the title selected in the listbox.
P.S: Use the "pre" and "code" formatting provided beneath the textbox to highlight code in your posting.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
hellow to all ..
i am trying to return a parameter from sql statment that i insert , how can i do it ?
for example i have a sql statment that inset into a table i wanna when i insert a value to Return the indx that i just inset or created ...
if anyone can please direct me or help me i will be thankfull ....
|
|
|
|
|
http://www.developerfusion.co.uk/show/4278/3/[^]
In a nutshell:
// add a new parameter, with any name we want - its for our own use only
SqlParameter sqlParam = com.Parameters.Add("@ReturnValue", SqlDbType.Int);
// set the direction flag so that it will be filled with the return value
myParm.Direction = ParameterDirection.ReturnValue;
Then, after the stored procedure has been executed,
int returnValue = (int)com.Parameters["@ReturnValue"].Value
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
i want to creat a class named school.this class can be used in foreach.I know that i should used IEnumeratore or IEnumerable but problem.my class have a collection of different object. i mean i wish i coud have a loop statment like here foreach(student s in school) or foreach(teacher t in school)
|
|
|
|
|
Your object needs to expose properties that represent the collection of students and teachers, so you can do
foreach(student s in mySchool.Students)
You can't vary your enumerator by return type, you can't do that for any method.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
You cant do that, but you could provide two properties, say Students and Teachers,
that return a collection of students and teachers respectively.
Then you can do foreach (Student s in school.Students) {...}
Alternatively you can have both Student and Teacher inherit from the same base class
(say Person) and do:
foreach (Person p in school) {
Teacher t=p as Teacher;
if (t!=null) { do teacher stuff }
}
and similar for students.
Luc Pattyn
|
|
|
|
|
thanks
but i things it has a solation.i have two class named teacher and student in my school collection.can i override equle method of each class to determine in foreach.or can i used generic collections
|
|
|
|
|
Hi,
foreach insists on matching types, all elements your enumerator offers must match the
type you mention inside foreach (or be derived from it), hence my Person suggestion
(although object would do too !).
I am not absolutely sure about generics, but I expect exactly the same:
in a teacher collection you can put teachers;
in a persons collection you can put teachers and students, but enumerating them would
result in persons, hence teachers as well as students.
If you insist on having different types (Student and Teacher) in a single collection,
then I strongly suggest you use the "as" statements I showed before. It works
very well for me.
Luc Pattyn
|
|
|
|
|
hi.
Thanks for your suggestion.I think your solation is the best.
|
|
|
|
|
Hmm, I don't like this use of foreach at all. Why? I don't see school as collection of students and teachers - Students and teachers are in school.
You can have properties of type StudentCollection and TeacherCollection . Then do foreach(Student s in school.Students) .
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
|
|
|
|
|
Yes, that's the best way, look at DataTable, there are .Columns and .Rows, each can be enumerated.
|
|
|
|
|
I am using Bitmap imgBold = Bitmap.FromFile("bold.bmp"); to retrieve a bitmap file, but when I try to compile the program, it says that it can't directly convert an Image object into a Bitmap object. It appears as though the Bitmap.FromFile method returns an Image object... Is there a method of the Image class that will allow me to convert the Image into a Bitmap ? The reason I need it to be a bitmap is that I need to set the transparency color. You can't do this with an Image object.
-----
Note: *** Never give me an answer have anything to do with Visual Studio. I don't have this program, and it'll be that way for a long, long time. ***
|
|
|
|
|
Why don't you simply cast the Image to Bitmap?
Bitmap imgBold = (Bitmap)Bitmap.FromFile("bold.bmp");
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Try this:
Bitmap imgBold = (Bitmap) Bitmap.FromFile("bold.bmp");
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hi Max,
you can use a stream instead of FromFile, just open a file stream and do:
Bitmap imgBold=new Bitmap(stream);
Luc Pattyn
|
|
|
|
|
You should never do a direct cast. Do this instead
Bitmap bm = Bitmap.FromFile("Blah") as Bitmap;
the 'as' operator will return null if the object is not a valid target for the cast. A cast will just blow up.
In this case, you know it will work, but it's just neater to get into the habit of doing it this way.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Christian Graus wrote: You should never do a direct cast. Do this instead
Bitmap bm = Bitmap.FromFile("Blah") as Bitmap;
the 'as' operator will return null if the object is not a valid target for the cast. A cast will just blow up.
Well, it's not always the best idea to postpone the error message as long as possible.
The code is more maintainable if an error occurs as close to the source as possible. If a cast doesn't work, it's easier to find the cause if the error message comes at the cast, than if it comes somewhere later in the code because of a reference mysteriously turning null.
Using as only serves a purpose if you actually check for null afterwards.
Also, in this case if the cast fails, you will lose the reference to the original object, which means that you won't be able to dispose it.
---
single minded; short sighted; long gone;
|
|
|
|
|
Guffa wrote: Using as only serves a purpose if you actually check for null afterwards.
Obviously, yes.
Guffa wrote: Also, in this case if the cast fails, you will lose the reference to the original object, which means that you won't be able to dispose it.
Oh, good point...
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Guffa wrote: Also, in this case if the cast fails, you will lose the reference to the original object, which means that you won't be able to dispose it.
Wouldn't I also loose the reference to the original object if the cast succeeds and therefore dispose it before doing this anyway.?
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Stefan Troschütz wrote: Wouldn't I also loose the reference to the original object if the cast succeeds
No. The type of the reference variable doesn't matter. A reference is a reference. If you want a reference to the object as the original, you can just cast the reference to the actual type.
---
single minded; short sighted; long gone;
|
|
|
|
|
Ah, I think I misunderstood your post. I thought with original object you were refering to the object that was referenced by the Bitmap variable before doing Bitmap bm = Bitmap.FromFile("Blah") as Bitmap but of course that is nonsense as the variable is declared in this line. So with original object you mean in this special case the Image object returned by FromFile , right?
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Stefan Troschütz wrote: So with original object you mean in this special case the Image object returned by FromFile, right?
Right.
---
single minded; short sighted; long gone;
|
|
|
|