|
Hi,
I am suppose to read XML files and extract some data from certain nodes based on its attribute. What I have done is to use XmlTextReader and loop through, using select case and hardcode (inefficient and poor practice) the nodes to be extracted. I have used XmlTextReader instead of XmlDocument initially as I would not be needing Xpath. Now, I would like to know if there are ways to select the nodes based on part of its attribute name like using wildcards. I have tried using Xpath but no success. Essentially, I want to select all the nodes with attributes beginning with a certain string eg) Wanted[…., regardless of the remaining text in the attribute name field.
Can anybody please kindly point to me how to go about doing it if possible? Any advice will be greatly appreciated.
Below are sample of my code and xml file.
reader = new XmlTextReader(link);
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Element:
if (reader.Name == "A") //To select some nodes w/o attributes
{…. }
if (reader.MoveToFirstAttribute()) {
switch (reader.GetAttribute(0)) //To select somes nodes based on attributes.
{
case "Wanted[zxx]":
…
break;
case "Wanted[yyy]":
…
…
default:
break;
….
- <Root>
<A>XXX</A>
….
- <Elements>
<Element name="Num">XXX</Element>
<Element name="xxx">xxx</Element>
<Element name="B1">1424</Element>
<Element name="Unwanted1">xxx</Element>
<Element name="Unwanted2">xxx</Element>
<Element name="Wanted[XXX]">xxx</Element>
<Element name="Wanted[YYY]">xxx</Element>
<Element name="Wanted[ZZZ]">xxx</Element>
</Elements>
</Root>
|
|
|
|
|
drifters wrote: Now, I would like to know if there are ways to select the nodes based on part of its attribute name like using wildcards.
I don't think so.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Oh no. If that's the case than I'll have to hardcode the cases. Thanks for the help. Any other view or advice will be greatly appreciated.
|
|
|
|
|
Hi!
Im currently playing around with making a Keylogger (nothing malicious, I promise) and ive gotten everything to work properly thus far, but one feature I think would be helpful would be recognizing what window currently has focus for each keystroke, i.e. if "hello" is typed in an internet explorer window, and then "c# programming" is typed in a firefox window, is there any way for my application to both get the kaystrokes, and the window with focus... making me able to do something like this:
Internet Explorer - The Code Project:
hello
Mozilla Firefox - The Code Project:
c# programming
Hopefully ive been clear on what I would like, any help would be much appreciated. Thanks!
Dirk Williams
|
|
|
|
|
Hi,
you can get a window handle and then either get the window's title, or scan the
process list (Process class) to find the process it belongs to. Some PInvoke
would be required:
[DllImport("user32")]
public static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll")]
public static extern void GetWindowText(IntPtr hWnd, StringBuilder sb, int capacity);
|
|
|
|
|
Hello everyone,
I am using the following code to specify a window to receive mouse and keyboard messages from the video window.
IVideoWindow.put_MessageDrain(this.DvdPanel.Handle);
I was wondering if I can do the following:
1- Can I distinguish between the right and the left mouse click?
2- Can I assign seprerate events to the mouse clicks?
- I would like to have ContextMenu once the right mouse is clicked; and follow the menu available on the Video Window once the left mouse is clicked.
Thank you very much and have a great day.
Khoramdin
|
|
|
|
|
What is an IVideoWindow ?
1 - in your event handler, you can. It's part of the event args
2 - no
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Helo Christian,
Thank you for your help. IVideoWindow is a DirectShow Interface. It is used for rendering Video images. If I am not mistaken your answer still stays the same regarding the mouse click. As I mentioned I can detect mouse click but I am unable to seperate the Left from Right mouse click.
Thank you very much for your help and have a great day.
Khoramdin
|
|
|
|
|
hi all,
let's say i have the following code:
public void GetAuthors_Click(Object sender, EventArgs E) <br />
{<br />
String selectCmd = "select * from Authors where state = @State";<br />
<br />
SqlConnection myConnection = new SqlConnection("server=(local)\\NetSDK;database=pubs;Trusted_Connection=yes");<br />
SqlDataAdapter myCommand = new SqlDataAdapter(selectCmd, myConnection);<br />
<br />
myCommand.SelectCommand.Parameters.Add(new SqlParameter("@State", SqlDbType.NVarChar, 2)); myCommand.SelectCommand.Parameters["@State"].Value = MySelect.Value;<br />
<br />
DataSet ds = new DataSet();<br />
myCommand.Fill(ds, "Authors");<br />
<br />
MyDataGrid.DataSource= ds.Tables["Authors"].DefaultView;<br />
MyDataGrid.DataBind();<br />
}
there is a text file i read with lines as follows:
DECLARE @VAR0 VARCHAR(40) --Variable0<br />
DECLARE @VAR1 INT --Variable1<br />
DECLARE @VAR2 BIT --Variable2
such that the second column gets stored in string[] strVarNames (i.e. strVarNames[1] = "@VAR1")
third column gets stored in string[] strVarTypes (i.e. strVarTypes[1] = "INT")
my question is in the following line from the above code:
myCommand.SelectCommand.Parameters.Add(new SqlParameter("@State", SqlDbType.NVarChar, 1));
how do i replace the 2nd parameter type as in the following example?
myCommand.SelectCommand.Parameters.Add(new SqlParameter(strVarNames[1], ***HOW from strVarTypes[1]?***, 1));
Thank you in advance.
I am a SysAdmin, I battle my own daemons.
|
|
|
|
|
First of all, please tell me you're not really putting all this code in your click event handler ?
Basically, if you have a string representation of the type, you probably need to write a switch statement that works out what type to return, or you may be able to use reflection.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I can't figure out the Mesh.Save() method. Does anyone know how to use this properly? I want to save my mesh data to a .x file so that I can use it in other programs, but I can't figure out this method.
-----
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. ***
|
|
|
|
|
What API are you using? (Managed DX? XNA?)
p.s. your signature sounds like something heard from a whiny slashdot linux fanboy. It discourages me, and probably others, from replying to your posts.
|
|
|
|
|
hello everybody,
I'm currently writing an Poker Odds Calculator.
I want this programm to read some informations from Online Poker Rooms like Pokerstars or PartyPoker. But the big problem that I have right now is that I dont know how to collect this Informations (like what text is stored in a textbox...) and transfer it to my Application so that I can calculate with it.
I searched the Internet but I didnt find anything.
Can you give me some inspirations?
This would be very great.
|
|
|
|
|
Do PartyPoker et al have a public API you could code against?
If not, you're left to stealing info from a behind-the-scenes browser (think System.Windows.Forms.WebBrowser). Such is possible, but not recommended because of difficulty and fragility, not to mention it's probably on shaky legal grounds.
|
|
|
|
|
I dont think that there is a special API, because other Odd Calculators (like 'Texas Calculatem' or 'Holdem Genius') need the Pokerwindow on top of the screen. So I think that they do Screenshots of special Parts of the Window and analyze this pictures. I'm not an very experienced Programmer so I dont know if this is correct.
But this sounds to me very 'unclean', there has to be a better way I think...
Here on Code Project I found an interesting article about a memory scanner. Would this be an option? I think I will write a little program to have a closer look to the memory befor I try the way with the screenshots.
How can I check the pokerprograms for an API?
A few weeks ago I found an article (dont know where right know) about someone who wanted to add his own controls to an external application. And he got it. Maybe it is possible to add a 'datareader' to the pokersoftware from which I can read the data in my calculator? (I dont know if this is possible and/or legal.)
I dont know what you mean with 'behind-the-scenes browser'. Can you explain it a bit for me? Or do you have a link?
I'm german, so if you dont understand something, please ask me...
|
|
|
|
|
hello
i made some report using crystal report .net
but when i ran the project on another pc exception appear like
this "CrystalDesision.Engine need it" or something
note i used crystaldesision propers to set page sizer to the report
and the project work on my pc completely
please help me
|
|
|
|
|
hi,
I used to meet the problem like you. I recoginized that when I made a Setup file, I forgot adding an assembly of Crystal Report. As a result, all tasks invovled CR can't run in another computer.
Please add this assembly in Setup file
It seem to be a solution or an answer.
|
|
|
|
|
Question 1) I'm just starting out in c# and am trying to figure out how to bind treeview and listview controls to the groovy new Windows RSS Platform. I see plenty of examples binding these controls to XML or databases, but none using the new platform. (FeedsManager, IFeedFolder, etc.)
Question 2) The new platform FeedsManager stores info under the application folder for the current system user. Can anyone suggest a way to create another instance of the feeds manager for different users and override the default directories that only pertain to the user signed in?
Thanks much!!
|
|
|
|
|
William,
Your question was well described and clear, unfortunately not too many people here have used the new Windows RSS platform. Perhaps if you ask this question on one of the RSS platform team member blogs on blogs.msdn.com, or in some other forum dedicated to this platform, you might get more help.
|
|
|
|
|
I use MS ReportViewer control in local mode in C# application which calls custom code module.
To reproduce issue:
1. In C# create Code module :
public class Util {
public static bool Empty(int nValue) {
return (nValue == 0);
}
}
2. In report hidden expression call use this function with integer field parameter like
<visibility>
<hidden>=Util.Empty(Fields!myintegerfield.Value))
Observed:
Error shown below.
How to force ReportViewer to call my function ?
Should I use some attribute in method declaration ?
Microsoft.Reporting.WinForms.LocalProcessingException: An error occurred during local report processing. ---> Microsoft.ReportingServices.ReportProcessing.ReportProcessingException: The Hidden expression for the textbox ‘Textbox23’ contains an error: Overload resolution failed because no Public 'Empty' is most specific for these arguments:
'Public Shared Function Empty(nValue As Integer) As Boolean':
Not most specific.
at Microsoft.ReportingServices.ReportProcessing.ReportRuntime.RegisterRuntimeErrorInExpression(VariantResult& result, Exception e, IErrorContext iErrorContext, Boolean isError)
at Microsoft.ReportingServices.ReportProcessing.ReportRuntime.EvaluateStartHiddenExpression(Visibility visibility, IVisibilityHiddenExprHost hiddenExprHostRI, ObjectType objectType, String objectName)
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.ProcessingContext.ProcessReceiver(Int32 uniqueName, Visibility visibility, IVisibilityHiddenExprHost visibilityExprHostRI, ObjectType objectType, String objectName)
at Microsoft.ReportingServices.ReportProcessing.ReportItemInstanceInfo.Microsoft.ReportingServices.ReportProcessing.IShowHideReceiver.ProcessReceiver(ProcessingContext context, Int32 uniqueName)
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.RuntimeRICollection.EvalReportItemAttr(ReportItem reportItem, ReportItemInstance riInstance, ReportItemInstanceInfo riInstanceInfo, ProcessingContext processingContext)
at Microsoft.ReportingServices.ReportProcessing.ReportItemInstanceInfo.ConstructorHelper(ProcessingContext pc, ReportItem reportItemDef, ReportItemInstance owner)
at Microsoft.ReportingServices.ReportProcessing.ReportItemInstanceInfo..ctor(ProcessingContext pc, ReportItem reportItemDef, ReportItemInstance owner, Int32 index)
at Microsoft.ReportingServices.ReportProcessing.TextBoxInstance..ctor(ProcessingContext pc, TextBox reportItemDef, Int32 index)
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.RuntimeRICollection.CreateTextBoxInstance(TextBox textBox, ProcessingContext processingContext, Int32 index, IScope containingScope)
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.RuntimeRICollection.CreateInstance(ReportItem reportItem, Boolean setupEnvironment, Int32 index)
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.RuntimeRICollection.CreateInstances(ReportItemColInstance collectionInstance, ReportItemCollection reportItemsDef)
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.RuntimeRICollection.CreateInstance(ReportItem reportItem, Boolean setupEnvironment, Int32 index)
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.RuntimeRICollection.CreateInstances(ReportItemColInstance collectionInstance, ReportItemCollection reportItemsDef)
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.RuntimeRICollection.CreateInstances(ReportItemColInstance collectionInstance, Boolean ignorePageBreaks, Boolean ignoreInstances)
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.RuntimeTableObj.CreateRowInstances(ProcessingContext processingContext, RuntimeRICollectionList rowRICols, TableRowInstance[] rowInstances, Boolean repeatOnNewPages, Boolean enterGrouping)
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.RuntimeTableGroupLeafObj.CreateInstance()
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.RuntimeGroupLeafObj.Traverse(ProcessingStages operation)
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.RuntimeGroupLeafObj.TraverseAllLeafNodes(ProcessingStages operation)
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.RuntimeGroupingObj.Traverse(ProcessingStages operation, Boolean ascending)
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.RuntimeGroupRootObj.CreateInstances(ReportItemInstance riInstance, IList instanceList, RenderingPagesRangesList pagesList)
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.RuntimeTableObj.CreateInstances(ReportItemInstance riInstance, IList instanceList, RenderingPagesRangesList pagesList)
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.RuntimeRICollection.CreateInstance(ReportItem reportItem, Boolean setupEnvironment, Int32 index)
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.RuntimeRICollection.CreateInstances(ReportItemColInstance collectionInstance, ReportItemCollection reportItemsDef)
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.Merge.CreateInstances(ParameterInfoCollection parameters, Boolean noRows)
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.Merge.Process(ParameterInfoCollection parameters, Boolean mergeTran)
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.ProcessReport(Report report, ProcessingContext pc, ProcessingContext context)
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.ProcessReport(Report report, ProcessingContext pc, Boolean snapshotProcessing, Boolean processWithCachedData, GetReportChunk getChunkCallback, ErrorContext errorContext, DateTime executionTime, CreateReportChunk cacheDataCallback, ProcessingContext& context)
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.RenderReport(IRenderingExtension renderer, DateTime executionTimeStamp, GetReportChunk getCompiledDefinitionCallback, ProcessingContext pc, RenderingContext rc, CreateReportChunk cacheDataCallback, Boolean& dataCached)
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.RenderReport(IRenderingExtension renderer, DateTime executionTimeStamp, GetReportChunk getCompiledDefinitionCallback, ProcessingContext pc, RenderingContext rc)
at Microsoft.Reporting.LocalService.RenderWithDataCache(PreviewItemContext itemContext, ParameterInfoCollection reportParameters, IEnumerable dataSources, DatasourceCredentialsCollection credentials, IRenderingExtension renderer, ReportProcessing repProc, CreateAndRegisterStream createStreamCallback, ReportRuntimeSetup runtimeSetup)
at Microsoft.Reporting.LocalService.Render(PreviewItemContext itemContext, Boolean allowInternalRenderers, ParameterInfoCollection reportParameters, IEnumerable dataSources, DatasourceCredentialsCollection credentials, CreateAndRegisterStream createStreamCallback, ReportRuntimeSetup runtimeSetup, ProcessingMessageList& warnings)
at Microsoft.Reporting.WinForms.LocalReport.InternalRender(String format, Boolean allowInternalRenderers, String deviceInfo, CreateAndRegisterStream createStreamCallback, Warning[]& warnings)
--- End of inner exception stack trace ---
at Microsoft.Reporting.WinForms.LocalReport.InternalRender(String format, Boolean allowInternalRenderers, String deviceInfo, CreateAndRegisterStream createStreamCallback, Warning[]& warnings)
at Microsoft.Reporting.WinForms.LocalReport.InternalRender(String format, Boolean allowInternalRenderers, String deviceInfo, String& mimeType, String& encoding, String& fileNameExtension, String[]& streams, Warning[]& warnings)
at Microsoft.Reporting.WinForms.ProcessingThread.ProcessThreadMain(Object arg)
Andrus
|
|
|
|
|
I have custom report viewer control in form.
Form has the following code in keypress event:
private void BaseForm_KeyPress(object sender, KeyPressEventArgs e) {
if ((int)e.KeyChar == (int)System.Windows.Forms.Keys.Escape) {
Close();
}
}
I View report containing many pages.
I Click in scroll down button in vertical scoll bar and hold down mouse left button while clicked.
I Release mouse button.
I Notized that form scrolls down continuously even
when mouse button is released.
I Press Esc key.
Observed:
Thread exception Cannot access a disposed object.
Object name: 'VScrollBar'.
How to fix this error and continuous scrolling ?
Thread exception Cannot access a disposed object.
Object name: 'VScrollBar'.
Stack trace: at System.Windows.Forms.Control.CreateHandle()
at System.Windows.Forms.Control.get_Handle()
at System.Windows.Forms.Control.set_CaptureInternal(Boolean value)
at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollBar.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Andrus
|
|
|
|
|
Hi,
I guess the following is happening:
1. continued scrolling: keeping the mouse button down launches several Windows messages
that get processed one after another; if the processing takes longer than the autorepeat
interval, they accumulate, and after you release the mouse the processing will continue
for a while. Probably your processing is too slow. I suggest you add some logging
(with millisecond time resolution) to the mouse down, mouse up, and scroll events.
If this confirms my theory, you should go find what makes your scrolling that slow,
and fix it.
2. disposed: once a KeyPress event is fired, you close the form, causing it (and all
its content) to disappear; if any more events have been queued in the mean time,
they may not find their control any more (such as VScrollBar). This may be a side effect
of problem 1 !
Hope this helps.
|
|
|
|
|
Luc,
Luc Pattyn wrote: you should go find what makes your scrolling that slow,
and fix it.
thank you very much for excellent explanation.
I'm using report viewer from fyireporting.com
Some reports may take a lot of time to scroll. It is really not possible to speed the scolling up.
How to remove the error message which occurs after pressing esc ?
Is it possible to clear message queue or is the other solution ?
Andrus.
Andrus
|
|
|
|
|
Hi,
I guess there is a solution, even to work around bugs/shortcomings of some
embedded control, but it requires advanced techniques:
IDEA 1
if you are in charge of the Form, you can override the good old WndProc,
by creating a method:
protected override void WndProc(ref Message m) {}
By doing so all low-level windows messages for that form will be offered to it,
and you can selectively disregard the ones you dont like, and let the system
handle only the ones you do like.
If you are unfamiliar with WM_... messages d(such as WM_SHOW) defined
in C/C++ file winuser.h you are out of luck...
IDEA 2
if you can figure out somehow that scrolling is still going on, you could
postpone the Form.Close() when ESC is pressed.
Maybe, just maybe, it is sufficient to do an Application.DoEvents() before
calling Close(), but I am not sure at all this will work.
Good luck !
|
|
|
|
|
Luc Pattyn wrote: IDEA 1
Thank you. Unfortunately, I'm new to C# and have no knowledge how to implement this.
Luc Pattyn wrote: if you can figure out somehow that scrolling is still going on, you could
postpone the Form.Close() when ESC is pressed.
I have no knowledge how to dedect scrolling.
I set thread exception handler in startup like
public static void Main() {<br />
Application.ThreadException +=<br />
new System.Threading.ThreadExceptionEventHandler(App_ThreadException);
How to ignore thread error when esc is pressed ?
I think it must be possbile to ignore error message caused by pressing esc.
However, how to store error message handling ?
Should I use timer or is there simpler way ?
Maybe, just maybe, it is sufficient to do an Application.DoEvents() before
calling Close(), but I am not sure at all this will work.
I tried code:
protected override void OnKeyDown(KeyEventArgs e) {<br />
if (e.KeyCode == Keys.Escape) {<br />
Application.DoEvents();<br />
FindForm().Close();<br />
} else<br />
base.OnKeyDown(e);<br />
}
but thread error still occurs.
I can reproduce this error on 2.66 MHZ core duo also when I hold down mouse button and press Esc in scroll time. So improving scrolling speed does not help.
Andrus
|
|
|
|
|