|
Ok, first of all here is the link to the MSDN topic with the example: XmlNode.SelectSingleNode Method (String, XmlNamespaceManager)[^]
To make it easier for you here is the example given there:
<bookstore xmlns="http://www.lucernepublishing.com">
<book>
<title>Pride And Prejudice</title>
</book>
</bookstore>
The following C# code selects the first book node:
XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
nsmgr.AddNamespace("ab", "http://www.lucernepublishing.com");
XmlNode book = doc.SelectSingleNode("//ab:book", nsmgr);
Your procedure does not work because your XPath expression is still looking for unqualified elements. Xpath does not offer an default namespace feature as XML files, at least I do not know of such a feature. Therefore, you have to prefix all element names with a specific prefix that maps to the right namespace URI (this mapping is what the namespace manager is for). Since your XML file makes use of a default namespace, it's quite likely that passing documents name table is not sufficient and you are required to add a prefix-namespaceUri-mapping as shown in the example.
[edit]
I was right :-> MSDN states:
"If the XPath expression does not include a prefix, it is assumed that the namespace URI is the empty namespace. If your XML includes a default namespace, you must still add a prefix and namespace URI to the XmlNamespaceManager; otherwise, you will not get a node selected. For more information, see Select Nodes Using XPath Navigation[^]."
[/edit]
AndrusM wrote: Where to download complete .NET + C# documentation for fast offline view ?
Some days ago, someone posted in this forum that you cannot download the documentation for free. You can get it on DVD, but for this you need a MSDN subscription for some hundred dollars if i recall the posting right.
AndrusM wrote: After I press F1 key, it takes 1-2 minutes for documentation viewer to open
Maybe, you can speed this up. Open the options of Visual Studio (available under menu item "extras"). Then go to "environment>help>online". At the top edge, you can define where Visual Studio looks for the requested help first. By default, it first tries to lookup online, what may be the reason for the long delay.
-- modified at 16:28 Tuesday 13th February, 2007
"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
|
|
|
|
|
Thank you very much for help.
I tried
string GetDefaultReport() {
Stream stream = GetType().Assembly.GetManifestResourceStream
("mynamespace.DefaultReport.xml");
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Load(stream);
XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDocument.NameTable);
nsmgr.AddNamespace("def", "http://schemas.microsoft.com/SQLServer/reporting/reportdesigner");
XmlNode node = xmlDocument.SelectSingleNode("/def:DataSource/def:ConnectionProperties/def:ConnectString", nsmgr );
....
but SelectSingleNode() still returns null.
What I'm doing wrong ?
In Help / Online I have radio button in choice "Try local only, not online".
In first attepmpt in C# Express 2005 when I highlight some item and press F1, it takes 1-2 minutes to open help window. hdd led is on and cpu usage is 10 .. 20% so I think that this time is wasted for reading data from hard disk.
I have Acer Travelmate 273LC notebook with 1.7 GHz Mobile Intel Pentium, 256 MB RAM, 20 GB Ultra ATA/100 HDD, no other applications opened.
Andrus
|
|
|
|
|
The default namespace URI is "http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition" not "http://schemas.microsoft.com/SQLServer/reporting/reportdesigner".
Furthermore, according to the XML file shown in your original post the XPath expression should be "/def:DataSources/def:DataSource/def:ConnectionProperties/def:ConnectString".
AndrusM wrote: In first attepmpt in C# Express 2005 when I highlight some item and press F1, it takes 1-2 minutes to open help window. hdd led is on and cpu usage is 10 .. 20% so I think that this time is wasted for reading data from hard disk.
Mmh, I honestly do not know how to resolve this. Could be your working memory is to small and windows needs to swap something into virtual memory (according to MSDN your system does not meet the system requirements of VS 2005). Maybe your hard drive is defragmented and therefore searching needs some time. Maybe it's a mix of both. Hard to tell.
"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
|
|
|
|
|
Thank you. I tried it but
node.InnerText = "test";
still causes null reference exception.
Complete test case is in bottom of this message.
I think I must buy new notebook for VS development. Maybe this solves the issue. I'll try to find 7400 RPM disk and 1 GB RAM. Currently I have 5400 RPM disk. I have read somewhere that MS and Intel have made a contract. According to this MS releases new software every year which forces people to by new hardware.
using System.Xml;
class Program {
const string s = @"<?xml version='1.0' encoding='utf-8'?>
<Report xmlns='http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition'
xmlns:rd='http://schemas.microsoft.com/SQLServer/reporting/reportdesigner'>
<DataElementStyle>ElementNormal</DataElementStyle>
<RightMargin>0.25in</RightMargin>
<Body>
<ReportItems>
<List Name='list1'>
<DataInstanceName>Row</DataInstanceName>
<NoRows>Selliseid andmeid pole</NoRows>
<Style />
<DataSetName>Data</DataSetName>
<ReportItems>
<Textbox Name='Phone'>
<Style>
<PaddingLeft>2pt</PaddingLeft>
<PaddingBottom>2pt</PaddingBottom>
<PaddingTop>2pt</PaddingTop>
<PaddingRight>2pt</PaddingRight>
</Style>
<ZIndex>1</ZIndex>
<CanGrow>false</CanGrow>
<Value>=Fields!Kood.Value</Value>
<Left>1.5in</Left>
<Width>1in</Width>
<Height>14pt</Height>
</Textbox>
<Textbox Name='ContactName'>
<Style>
<PaddingLeft>2pt</PaddingLeft>
<PaddingBottom>2pt</PaddingBottom>
<PaddingTop>2pt</PaddingTop>
<PaddingRight>2pt</PaddingRight>
</Style>
<Width>1.5in</Width>
<Height>14pt</Height>
<CanGrow>false</CanGrow>
<Value>=Fields!Nimetus.Value</Value>
</Textbox>
</ReportItems>
</List>
</ReportItems>
<Style />
<Height>0.25in</Height>
<ColumnSpacing>0.25in</ColumnSpacing>
<Columns>1</Columns>
</Body>
<TopMargin>0.5in</TopMargin><DataSources>
<DataSource Name='DS1'>
<ConnectionProperties>
<DataProvider>PostgreSQL</DataProvider>
<ConnectString></ConnectString>
</ConnectionProperties>
</DataSource>
</DataSources>
<DataSets>
<DataSet Name='Data'>
<Query> <DataSourceName>DS1</DataSourceName>
<CommandText>SELECT * FROM nomenkla</CommandText>
</Query>
<Fields>
<Field Name='Nimetus'>
<DataField>nimetus</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name='Kood'>
<DataField>kood</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
</Fields>
</DataSet>
</DataSets>
<LeftMargin>0.25in</LeftMargin>
<BottomMargin>0.5in</BottomMargin>
<Width>2.5in</Width>
<PageHeader>
<Height>0pt</Height>
</PageHeader>
<PageFooter>
<Height>0pt</Height>
</PageFooter>
</Report>";
static void Main() {
GetDefaultReport(s);
}
static string GetDefaultReport(string s) {
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.InnerXml = s;
XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDocument.NameTable);
nsmgr.AddNamespace("def", "http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition");
XmlNode node = xmlDocument.SelectSingleNode("/def:DataSources/def:DataSource/def:ConnectionProperties/def:ConnectString", nsmgr);
node.InnerText = "test";
return xmlDocument.InnerXml;
}
}
Andrus
|
|
|
|
|
AndrusM wrote: XmlDocument xmlDocument = new XmlDocument();
xmlDocument.InnerXml = s;
What's this s? If it is a string representation of a XML file that you want to assign to the document, use the XmlDocument.LoadXml method instead.
"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
|
|
|
|
|
Thank you.
I changed the line to
xmlDocument.LoadXml(s);
but node value is still null.
Andrus
|
|
|
|
|
Ok, since the code should work as it is, I would first check whether the XmlDocument instance really contains what you expect it to. Easiest way, would be writing the document to some test file by using the XmlDocument.Save method.
"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 added a line
xmlDocument.Save(@"c:\test.xml");
text.xml seems to be OK.
So is this .NET bug ?
text.xml contains:
’╗┐<?xml version="1.0" encoding="utf-8"?>
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
<DataElementStyle>ElementNormal</DataElementStyle>
<RightMargin>0.25in</RightMargin>
<Body>
<ReportItems>
<List Name="list1">
<DataInstanceName>Row</DataInstanceName>
<NoRows>Selliseid andmeid pole</NoRows>
<Style />
<DataSetName>Data</DataSetName>
<ReportItems>
<Textbox Name="Phone">
<Style>
<PaddingLeft>2pt</PaddingLeft>
<PaddingBottom>2pt</PaddingBottom>
<PaddingTop>2pt</PaddingTop>
<PaddingRight>2pt</PaddingRight>
</Style>
<ZIndex>1</ZIndex>
<CanGrow>false</CanGrow>
<Value>=Fields!Kood.Value</Value>
<Left>1.5in</Left>
<Width>1in</Width>
<Height>14pt</Height>
</Textbox>
<Textbox Name="ContactName">
<Style>
<PaddingLeft>2pt</PaddingLeft>
<PaddingBottom>2pt</PaddingBottom>
<PaddingTop>2pt</PaddingTop>
<PaddingRight>2pt</PaddingRight>
</Style>
<Width>1.5in</Width>
<Height>14pt</Height>
<CanGrow>false</CanGrow>
<Value>=Fields!Nimetus.Value</Value>
</Textbox>
</ReportItems>
</List>
</ReportItems>
<Style />
<Height>0.25in</Height>
<ColumnSpacing>0.25in</ColumnSpacing>
<Columns>1</Columns>
</Body>
<TopMargin>0.5in</TopMargin>
<DataSources>
<DataSource Name="DS1">
<ConnectionProperties>
<DataProvider>PostgreSQL</DataProvider>
<ConnectString>
</ConnectString>
</ConnectionProperties>
</DataSource>
</DataSources>
<DataSets>
<DataSet Name="Data">
<Query>
<DataSourceName>DS1</DataSourceName>
<CommandText>SELECT * FROM nomenkla</CommandText>
</Query>
<Fields>
<Field Name="Nimetus">
<DataField>nimetus</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="Kood">
<DataField>kood</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
</Fields>
</DataSet>
</DataSets>
<LeftMargin>0.25in</LeftMargin>
<BottomMargin>0.5in</BottomMargin>
<Width>2.5in</Width>
<PageHeader>
<Height>0pt</Height>
</PageHeader>
<PageFooter>
<Height>0pt</Height>
</PageFooter>
</Report>
Andrus
|
|
|
|
|
No, there is no bug. Seems the XPath expression is still not right. Try "/def:Report/def:DataSources/def:DataSource/def:ConnectionProperties/def:ConnectString" or "//def:DataSources/def:DataSource/def:ConnectionProperties/def:ConnectString"..
"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
|
|
|
|
|
Thank you very much. It works. Excellent.
Assigning string to InnerXML property works also.
I have no idea why you ordered to use LoadXML()
Andrus
|
|
|
|
|
I need to convert datareader to stongly typed entity list.
The following procedure returns error.
How to fix this ?
List<xEntity> CreateEntityList<xEntity>(IDataReader dataReader) {
List<xEntity> list = new List<xEntity>();
while (dataReader.Read()) {
object[] o;
dataReader.GetValues(o);
list.Add(o);
}
dataReader.Close();
return list;
}
Andrus
|
|
|
|
|
I had some reports that were local and pointed at a DataSet using an xsd file as the basis for creating the report, then using a stored procedure to fill the ds, assignig it to the report as the report source
oRpt.Load(_templatePath + _templateName);
oRpt.SetDataSource(ds);
now I have set up a webservice to provide the reports and I can assign an actual table to the report but can't seem to use one of the existing reports - as report keeps asking me to log into the MS SQL database - and since I am using the system authentication has me stumped.
Is there a way I can change the datasource of a webservice report before sending it across - or after?
Thanks
David Bambrick
|
|
|
|
|
What is best method to do this on Order Details data grid, when user select ProductID ProductPrice is automatically filled with value from Product table... and is on save written to Order details (so if price changed in Product table it will not be automatically updated in order details table (only when user select new product)?
I already have idea, tried to do new table adapter that have parameter query that do just that, and have event celled edit call fill on new table adapter... only remaining problem is how to copy new value to existing tableadapter.
I tried some work around things... but none is very professional so I'm looking for some elegant solution.
So how to copy value from that table adapter to data grid cell if possible (I only managed to drag and drop new table adapter and create text box on form, so I copy value of text box to grid, not something I would like to do)?
|
|
|
|
|
OK this can give you some idea...
private void order_DetailsDataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e)<br />
{<br />
if (order_DetailsDataGridView.Columns[e.ColumnIndex].DataPropertyName == "ProductID")<br />
{this.getProductCurrentPriceTableAdapter.Fill<br />
(this.northWndDataSet.GetProductCurrentPrice, (int)order_DetailsDataGridView[e.ColumnIndex, e.RowIndex].Value);<br />
order_DetailsDataGridView[e.ColumnIndex + 1, e.RowIndex].Value = decimal.Parse(unitPriceTextBox.Text); <br />
}<br />
}
so instead last line I want something better, any idea?
|
|
|
|
|
|
Hello everyone,
I have a media player application which I am currently using the main WinForm to display the image. The main WinForm is actually where all my stuff are on inclusing the control panel.
I was wondering if it is possible to send the image to a panel which is embeded inside my main WinForm? If such a thing is possible could someone give me some hint on "How to do it?".
Thanx for your help.
Khoramdin
|
|
|
|
|
How have you got the media player displayed? Is it using the windows api, if so you should be able to just switch the hwnd of the form for the hwnd of the panel and there you go. Unless you're doing it some other way.
|
|
|
|
|
Hello,
I ran into the following situation. First, i'll list a small excerpt of the process list output from Process Explorer [^];
Process PID
System Idle Process 0
Interrupts n/a
DPCs n/a
cdas56e.exe 504
StartupMonitor.exe 3388
eclipse.exe 3396
javaw.exe 3052
emulator.exe 2752
jdbgagt.exe 3872
procexp.exe 1592
iexplore.exe 2168
taskmgr.exe 1536
procexp.exe 3688
explorer.exe 2172
multiDesk.exe 2164 The process that is bolded, namely eclipse.exe and it's children, is orphaned because the explorer.exe died for some reason. I started a new explorer from the taskmgr.exe application. The problem that I am trying to solve is that I can no longer access the eclipse.exe application after it's parent, explorer.exe, dies. (I tried to use the "Bring to Front" command from taskmgr.exe but that did not work because that option was turned off.)
How would I go about writing a program to reattach an orphan process(es) to a new explorer.exe process?
Sources, URL s, etc..., would be greatly appreciated.
Thanks,
|
|
|
|
|
Hello everyone,
I am trying to get some hotkey "Short-cut" for my application. I am currently using the following codes for a single key event and everything works fine.
switch(e.KeyCode)
{
case Keys.Right:
{
_Pacman.MovementDirection = MovementDirections.Right;
break;
}
case Keys.Left:
{
_Pacman.MovementDirection = MovementDirections.Left;
break;
}
case Keys.Down:
{
_Pacman.MovementDirection = MovementDirections.Down;
break;
}
case Keys.Up:
{
_Pacman.MovementDirection = MovementDirections.Up;
break;
}
}
I wish to have the case that "Ctrl" key to be added to these key events. Can someone tell me what I need to do to have this, please.
Thank you for your help.
Khoramdin
|
|
|
|
|
if (e.Control == true) {
switch(e.KeyCode)
{
case Keys.Right:
{
_Pacman.MovementDirection = MovementDirections.Right;
break;
}
...
}
}
"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
|
|
|
|
|
hey, I'm havening trouble trying to get the letter under the mouse
my purpose is to make each letter in a label select able or a button.
can any one help, i would be great if you do
Thanks
|
|
|
|
|
There's a Win32 API called WindowFromPoint, this will give you the window handle of the control you are over. From there, you can use GetWindowText, but working out what letter is under the mouse, will be a little more complex, you need to get the font details from the control, and work out how that font renders. A multi line control makes it even harder. I imagine getting it to work 100% of the time would be a very big job, indeed.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
yea it would be, i'll look into that and see how i go, my font is 'Lucida Console, 9pt'
which makes each letter the same width part.
thanks for that
|
|
|
|
|
I added both the convert and revert in title for completness. I am using the ArrayList.ToArray(typeof(byte)) now to return the byte array.
now I need to convert it back to an Arraylist. Cannot seem to figure that one out for some reason.
Any help would be appreciated.
Steve Welborn
Software Engineer
BitWise Solutions
|
|
|
|
|
Try this:
public ArrayList ToArrayList(byte[] buffer)
{
if (buffer == null || buffer.Length == 0)
return null;
ArrayList list = new ArrayList();
list.AddRange(buffer);
return list;
}
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|