|
hi
i unable to read an xml file, i write xml file successfully before facing any problem.
but when i want to read i unable to through, i saw lots of example of reading an xml file but
its read an element by specifying its value but
what if i do not know the value, i just want a dynamic interaction, that's it.
please help me out, it's urgent!!!!!!!!1
bhupendr singh
|
|
|
|
|
well you should use System.Xml.XmlDocument to load your xml e.g. doc.LoadXml(xmlString)
then you can do any of the following -
XmlNodeList nodeList = doc.DocumentElement.SelectNodes("//section");
this will select all nodes that are named and you can itterate through this XmlNodeList object.
System.Xml.XPath.XPathNavigator nav = doc.CreateNavigator();
probably better for you since you dont know the value then you can itterate through this object by calling its various methods e.g nav.MoveToNext();
|
|
|
|
|
my snippet of code look like this:
1.XmlDocument doc=new XmlDocument();
2.doc.LoadXml("c:\\bhupen\\bsdXml.xml");
3.string a=doc.ToString();
4.XPathNavigator nav=doc.CreateNavigator();
5.nav.MoveToFirstChild();
6.string b=nav.Value;
In this code i got an exception error:
An unhandled exception of type 'System.Xml.XmlException' occurred in system.xml.dll
Additional information: System error.
at line no. 2 means it unable to load xml.
other than this problem ref. line no. 6:
is this a proper way to reach sub element of the root element or
available any other suitable way.
please suggest.
Bhupendr Singh
|
|
|
|
|
ok
2. doc.loadXml only takes a string of xml you should use doc.load(filename)
3. a will contain a string value of the object name i.e. System.Document.XmlDocument if you want to get the xml in the file you should say string a = doc.innerXml
6. almost - string a = nav.current.value
|
|
|
|
|
Extract data and create xml for input
--------------------------------------------------------------------------------
Hi
I am given with a xml schema file.( with field name and datatype),
then along with a (*.unl file) with data's for the above schema file.
but without field names. each data is seperated by "|" character.
ie, like consider xml schema having field names as
Ex:
---
<xs:sequence>
<xs:element name="division" type="xs:int" minoccurs="0">
<xs:element name="location" type="xs:int" minoccurs="0">
<xs:element name="position" type="xs:string" minoccurs="0">
like this
and wheras (*.unl file) has values as follows
1|10|DAVID
1|10|JOHN
1|10|BECKER
...etc like so on.
Now what I have to do is that create a xml file along with schema and data's .
And later on use this xml file as input and have to create a report.
How to load these dta's intoa xml file for that particular schema.
how to program this.
pls help me to do this.
santhosh
|
|
|
|
|
|
I know subject sounds a bit odd but it's the most appropriate one I could come up with. After 1,5 year of c-sharping I cannot explain and solve my problem.
The thing is:
1. I'm working on my own inherited DataGrid class
2. I want to embed certain functionality in the grid (custom paging, sorting, filtering, etc.)
3. To ease programmatic creation of an instance of my control I introduced a collection class (AcidColumnCollection) of an object of AcidColumn type. This is really simple class which store information about the columns (if a column allows filtering, for instance).
4. The problem appears in ItemCreated method when I want to add a TextBox to the header cell (for filtering purposes). Have a look at this code snippet:
protected override void OnItemCreated(DataGridItemEventArgs e)
{
...
// insert glyphs in header cells for indication of order and texboxes
for(int i = 0; i < this.Columns.Count; i++)
{
// find a cell
TableCell tc = e.Item.Cells[i];
GenerateOrderInformation(tc, i);
GenerateFilterTextBoxes(tc, i);
}
...
}
Let's consider GenerateFilterTextBoxes method:
private void GenerateWhereTextBoxes(TableCell tc, int i)
{
string column = this.Columns[i].SortExpression;
// columns is an instance of AcidColumnCollection
// Filterable method checks whether a column which name is passed via this method's parameter should have a TextBox for filtering purposes.
if(columns.Filterable(column) == true)
{
// create controls to add
Label lblBreak = new Label();
TextBox txtBoxWhere = new TextBox();
// set properties
lblBreak.Text = " ";
// add them
tc.Controls.Add(lblBreak);
tc.Controls.Add(txtBoxWhere);
}
}
Basically I create AcidColumn object to store additional information about customised DataGrid columns. One of those is a property called Filterable. If it is true - a TextBox is added to that column. There no logic behind it so far, yet to be implemented. Simple as that.
What is the problem then? Well DataGrid events GO MAD - I click column 0 column 1 is sorted, I click column 2 - column 1 is sorted, I click on paging link, column 0 is sorted (!), the page is changed but the paging link does not change! It is really weird.
I made experiments and they ended in AcidColumnCollection.Filterable method. Look at this:
public bool Filterable(string p_name)
{
bool filterable = false;
foreach(AcidColumn col in this.List)
{
if(col.Name == p_name)
{
filterable = col.Filterable;
break;
}
}
return filterable;
}
ONLY if I use this collection method to examine filterable property and ONLY if I add TextBoxes to the datagrid header, the problem appears.
The last thing I did was replacing "return filterable" with "replace true" and... everything is FINE. PERF ECT. Change it back to filterable variable - the grid will not work.
Also if I use this Filterable method to check the property but DO NOT add any controls in GenerateWhereTextBoxes method - the grid beheaves normally.
I just do not know where the problem could lie. AcidColumn is a simple class. There's nothing behing Filterable property, nothing that could affect DataGrid events. And how come browsing through collection and checking its object properties in combination with adding controls to the grid generates such a strange problem!?
For your reference I'm enclosing Acid Column class:
public class AcidColumn
{
private string name;
private string type;
private bool filterable;
private int order;
public AcidColumn()
{
this.filterable = false;
}
public string Name
{
get { return name; }
set { name = value; }
}
public bool Filterable
{
get { return filterable ; }
set { filterable = value; }
}
}
Thanks for your advice,
Arek
|
|
|
|
|
I want to get access to the text contained within a pdf file (preferably without buying an expensive third party API). I have a copy of Adobe Acrobat reader which can actuall save as a text file which is fine I need to automate this.
Any ideas?
|
|
|
|
|
|
How can I display a ToolTip on a disabled control?
This ToolTip works fine:
checkbox.Enabled = true;<br />
toolTip.SetToolTip(checkbox, "tool tip");
This one is not visible:
checkbox.Enabled = false;<br />
toolTip.SetToolTip(checkbox, "tool tip");
toolTip.ShowAlways = true; seems to have no effect.
Is there anything like a ToolTip.ShowAlways property for the case that the control itself is not enabled?
|
|
|
|
|
Hi... thx for looking at my problem.
I got difficulties creating a dropdownbutton. I only manage to pick the DropDownButton from the list of style in my toolbar button property. I dunno how to go from here. Cannot find answer in MSDN help or internet. Is it a new feature in .Net2003? Pls help...
|
|
|
|
|
You need a ContextMenu. Close the toolbar buttons dialog, add a ContextMenu, add MenuItems, then go back to the toolbar buttons dialog and select your new ContextMenu as the DropDownMenu for the button.
_________________________________
Vote '1' if you're too lazy for a discussion
|
|
|
|
|
how can i make a window always on top in C#.NET
|
|
|
|
|
|
i wanted to know what microsoft sharepoint is....could anyone explain....??
|
|
|
|
|
In short, it's a Collaboration Server. But, since this question has nothing to do with C#, I'll let Microsoft explain it better, see SharePoint Portal Server 2003 Product Information[^].
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
i was wondering if anyone could tell me how i can find a alist of all the services on windows XP and start or stop a service. i would also like to know how to start or stop a process.
|
|
|
|
|
Don't know of a list, but System.Diagnostics has the Process class for fooling around with processes.
System.Diagnostics.Process p = System.Diagnostics.Process.GetProcessesByName("thatProcess");
will get you all thatProcess processes.
have fun
|
|
|
|
|
If you're talking specifically about windows services there is a serviceController class included in the framework which can list, start and stop services.
|
|
|
|
|
ServiceController Class[^] docs on MSDN.
It will let you do everything you want.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
i encountered a problem while using c# timer,
i declared the timer...
exerciseTimer = new System.Timers.Timer();
exerciseTimer.Elapsed += new ElapsedEventHandler(ExerciseTimeElapsed); exerciseTimer.Interval = exerciseTime;
exerciseTimer.Enabled = true;
exerciseTimer.Elapsed += new ElapsedEventHandler(ExerciseTimeElapsed);
exerciseTimer.Start();
:
and put a function that shows a window here...
private void TimeElapsed(object sender, ElapsedEventArgs e){
if(window.Visible = false)
window.Show();
}
}
i don't know why the window hangs when it opens?
please help me out.. i'm a newbie c# programmer and i don't know what to do.
|
|
|
|
|
why do you assign an ElapsedEventHandler twice?? You should only have to do that once. How long is exerciseTime?? cause if it is say 10 sec the form will only appear in 10 seconds. Also your if statement should have double = signs i.e.
if(window.vissible == true)
|
|
|
|
|
The System.Timers.Timer is designed for use with worker threads in a multi-threaded environment and can move among threads to handle the raised events.
So your handler for the Elapsed event isn't executed in the context of the same thread that created the timer and most likely also created the window you want to show. But accessing windows controls from threads other than the one which instanciated them has often weird results e.g. they're hanging.
So either use the System.Windows.Forms.Timer , which is designed for a single-threaded environment where UI threads are used to perform processing, or invoke the Show method of your window, so it gets executed on the thread that instantiated the control. For more information on the latter possibility, take a look at the docs for the Control.Invoke[^] method.
By the way, it's sufficient to subscribe the event handler once and calling Start after setting Enabled true is redundant, as it does exactly the same.
www.troschuetz.de
|
|
|
|
|
Hail to codeproject! i love you!
|
|
|
|
|