|
The problem is that your top-level element declares a default namespace (xmlns="http://www.w3.org/2005/Atom") that is valid for all nested elements. This means that your feed and entry have a qualified name of "{http://www.w3.org/2005/Atom}feed" or "{http://www.w3.org/2005/Atom}entry" respectively. Your XPath on the other hand is looking for unqualified feed and entry elements i.e. those declared in the empty namespace. Because your document does not contain such elements nothing is found. To resolve this use the overload of the Select method that takes an IXmlNamespaceResolver . Take a look at the example given by the respective MSDN topic and you should be able to work this out.
"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
|
|
|
|
|
sorry but I'm unclear on how to use the IXmlNamespaceResolver. Tried googling for example on the usage but still unclear. Anyone pls kindly point me in the right direction. Thanks.
|
|
|
|
|
part of my code is below:
XmlDocument myXmlDocument = new XmlDocument();
myXmlDocument.Load("sample.xml");
XmlNamespaceManager nsmanager = new XmlNamespaceManager(myXmlDocument.NameTable);
nsmanager.AddNamespace("ns", "http://www.w3.org/2005/Atom");
XPathNavigator nav = myXmlDocument.CreateNavigator();
XPathExpression expr;
expr = nav.Compile("feed/entry[title='Summary']");
expr.SetContext(nsmanager);
XPathNodeIterator iterator=nav.Select(expr);
XPathNavigator nav2 = iterator.Current.Clone();
listBox1.Items.Add((nav2.Value));
but the output i get contains not only nodes with title=Summary but all the nodes of feed in the XML posted earlier. Can anyone advise how to select <link href> to grab the address from the attribute. thanks.
|
|
|
|
|
As indicated before you have to use the overload of Select that takes an IXmlNamespaceResolver . In your case you pass in the XmlNamespaceManager object. Furthermore you need to qualify the elements in your XPath expression with the prefix defined for their namespace i.e. "ns:feed/ns:entry[ns:title='Summary']".
"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
|
|
|
|
|
I am wanting to use C# to open a page using a browser control (Windows App), call a JavaScript code segment on the page and then allow the code to execute.
Here is program flow:
Open my Windows App.
Browser control opens a page.
Page loads with a java button that when clicked runs the code I want to run.
C# calls the code, or simulates the button click.
Program waits for code execution.
Program exits.
I am not expecting someone to write the code, I just want to clarify that the code I am calling is not actually visible to the C# app I am writing.
Thanks for your time!
The only way to speed up a Macintosh computer is at 9.8 m/sec/sec.
|
|
|
|
|
I did this too.
Assuming that your browser control is named webBrowser1, use
webBrowser.Document.InvokeScript() method
It takes two parameters: the name of the JavaScript function and an array of objects representing it's parameters.
|
|
|
|
|
ComboBox control has got selectedindexchanged event. As the name suggest this event should fire when selected item change for the combobox. But this event fires even when the currently selected item is selected again from the dropdown list of combobox.
e.g.
if I have loaded following items in my combobox say
item1
item2
item3
item4
with item1 as selected when my application starts.
Now if from UI, I again select the "item1" (which is already selected in combo box) then also the selectedindexchanged event fires. In this case the index has not changed still the selectedindexchanged event fires. I find this bit strange.
Is there anyway to findout when the selected item has changed by User. I want some kind of notification when user indeed changes the combobox selected item (not when combobox.selecteditem is set through code)?
regards
KC
|
|
|
|
|
Hi All,
I have created a class which holds a method for impersonating a user and starting a process using the impersonated login.
I'm having a windows application wherein i start a process from my windows login say Process1 and another process using the impersonation method say Process2 (i'm calling notepad.exe in both logins).
When i'm copying a word from the notepad under Process1 and pasting it in the notepad under Process2, it should not get pasted. But instead it gets pasted.
Is there any possiblity that i can restrict the pasting event in the notepad.
Parimala
|
|
|
|
|
I want to make an User Control in VC# that can be used in VC6.
For that I have made a control in C# using 'Windows Control Library', which make dll file; But in VC6 to add a control only OCX files are requird.
So how to make an User Control in VC# that can be used in VC6
|
|
|
|
|
The only way is to create a COM based one. VC6 was written before C# existed, it plainly knows nothing about C#. COM can provide a common interface.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
I have a Windows Form application with a simple GUI that contains a progress bar. Pushing the button 'Start' on my form invokes some other project[ in same solution] classes that carry out a lot of calculations and database access. I want to show the user the progress of the program. The program is actually a loop of database migration that are handled.
My solution contains more the one project.
we have different layer.
Presentation layer.
bussines layer.
My question is: How do I make the progress bar update itself from other layer, when we dont have reference in bussines layer?
Thanks in advance for your help
|
|
|
|
|
If you don't have a reference to the business layer, how are you calling it ? If they are both exes, then the design sucks and you need inter process communication to make it work.
Usually, I'd have a business layer DLL and I'd use a delegate to send progress reports back from a worker thread.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Exception Sample :
static void Main(string[] args) {
try{
Console.WriteLine("Level 1");
try {
Console.WriteLine("Level 2");
goto exit;
}
finally {
Console.WriteLine("Level 2 Finished");
}
}
finally {
Console.WriteLine("Level 1 Finished");
}
exit: ;
}
What is the wrong in this code sample above?
If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
Are you asking @ sytanx or what.. It will compile successfully.
Jayant D. Kulkarni
Brainbench Certified Software Engineer in C#, ASP.NET, .NET Framework and ADO.NET
|
|
|
|
|
hi kulakarni,
thanks for the response.
actually today i took one pre assessment test in C#. they asked this question.
they gave me 5 options:
What is the console output for the code sample above?
Choice 1
Level 1
Level 2
Level 2 Finished
Level 1 Finished
Choice 2
Level 1
Level 2
Level 1 Finished
Choice 3
Level 1
Level 2
Choice 4
Level 1
Level 2
Level 1 Finished
Level 2 Finished
Choice 5
Level 1
Level 2
Level 2 Finished
which one is the correct out put?
Thanks,
Rahi
If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
It is obvious choice1. Because of the rule that finally block is always executed inspite of any excpetion is occured or not. In this case, inner most try and finally is executed first and then the outer one.
Jayant D. Kulkarni
Brainbench Certified Software Engineer in C#, ASP.NET, .NET Framework and ADO.NET
|
|
|
|
|
oho....thanks Kulakarni.
i know this but when i saw the question, i didn't understand the question first of all........now i came to know the correct answer!
Thanks,
Rahi
If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
The problem is that you are using GOTOs Get over that crutch quickly.
|
|
|
|
|
Hi everyone,
How to get Insert button status?
Thank You.
|
|
|
|
|
Is the following feasible?
I'm looking for a way to develop an application that is developed in dot NET that looks like a desktop application and can be run within a browser the same way a Java applet or an ActiveX application does.
Please advise.
|
|
|
|
|
My msn:
wangpc@msn.com
Welcome everyone!
|
|
|
|
|
I am sorry but I do not think people are here for making friends. Anyways if you have any .NET related questions, you will get answers.
Jayant D. Kulkarni
Brainbench Certified Software Engineer in C#, ASP.NET, .NET Framework and ADO.NET
|
|
|
|
|
THe best place to post this is in the soap-box there you will make more firends.
Go on, move the thread to the soap-box and see how welcoming people there will be,
|
|
|
|
|
The lounge is a good place to meet people. This forum is better for asking programming questions.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
I have one question... How do you get an image to show up on a windows form? I've got that you can use the this.BackgroundImage property of the window, but I want to be able to put it anywhere, like a ControlItem.
---
*** 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. ***
Description: A 13 Year Old Programming Wiz
The elementary kids were right! "1" + "1' does = "11"!
|
|
|
|