|
Hi!
I had this problem too and after a lot of effort i figured out that using DOM, there isn't any way you can rename an element directly. May be i am wrong but at least i couldn't find its solution.
I changed the structure of my xml file and used a generic name for xml element and stored the data as attribute...e.g.
<element1 attr="niv1">
<element2 attr="niv2">
</element2>
</element1>
This way you can easily modify the attributes of element.
Another possible way (if you don't want to change the structure of xml file) might be by storing the innerXml of node to be renamed, then delete that node and create new node with modified name and assign innerXml to that new node.
Hope that helps, if i have made any mistake please correct me. I would love to know if there is any other way of renaming an element.
Thanks,
Regards,
Affan Ahmad Toor
..................
QUAIDIAN FOR ONCE, QUAIDIAN FOR EVER!
|
|
|
|
|
I cant change the structure of my xml files, because I have over 4000 of them.
What I tried is to copy a node if it is named for example niv1, delete it, and create a new node with the new name and add the content that I copied erlier.
But I dont get it to work.
|
|
|
|
|
Phrone wrote: What I tried is to copy a node if it is named for example niv1, delete it, and create a new node with the new name and add the content that I copied erlier.
But I dont get it to work.
That's what I'd think is way to do it, what problem do you have with this approach?
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
dnh wrote: Phrone wrote:
What I tried is to copy a node if it is named for example niv1, delete it, and create a new node with the new name and add the content that I copied erlier.
But I dont get it to work.
That's what I'd think is way to do it, what problem do you have with this approach?
I'm not sure what I do wrong. And I've tried to find code samples to see how other done, but with no luck.
MSDN doesn't have much information about it either.
|
|
|
|
|
try doing this:
string nodeData = "";
XmlDocument xmlDoc = new XmlDocument();
XmlNode root = xmlDoc.DocumentElement();
XmlNodeList nodeList = root.GetElementByTagName("nav1");
XmlNode node = nodeList[0];
if(node!=null)
{
nodeData = node.InnerXml;
root.RemoveChild(node);
//Create new node with modified name
XmlElement newNode = xmlDoc.CreateElement("New nav1");
newNode.InnerXml = nodeData;
root.AppendChild(newNode);
}
hope that helps...
..................
QUAIDIAN FOR ONCE, QUAIDIAN FOR EVER!
|
|
|
|
|
This code gives me errors.
Error 1 'System.Xml.XmlDocument.DocumentElement' is a 'property' but is used like a 'method' U:\ModXML\ModXML\GUI.cs 265 43 ModXML
Error 2 'System.Xml.XmlNode' does not contain a definition for 'GetElementByTagName' U:\ModXML\ModXML\GUI.cs 266 49 ModXML
Affan Toor wrote: try doing this:
string nodeData = "";
XmlDocument xmlDoc = new XmlDocument();
XmlNode root = xmlDoc.DocumentElement();
XmlNodeList nodeList = root.GetElementByTagName("nav1");
XmlNode node = nodeList[0];
if(node!=null)
{
nodeData = node.InnerXml;
root.RemoveChild(node);
//Create new node with modified name
XmlElement newNode = xmlDoc.CreateElement("New nav1");
newNode.InnerXml = nodeData;
root.AppendChild(newNode);
}
hope that helps...
|
|
|
|
|
I'm going to be slightly annoying here but that is exactly what XSLT[^] was designed for. You can execute the transformations from .NET by using the XslTransformation (I think that's it's name) class.
|
|
|
|
|
I dont know so mutch about XSLT, but isn't it so that it doesn't change the element names only the apperance?
Ed.Poore wrote: I'm going to be slightly annoying here but that is exactly what XSLT[^] was designed for. You can execute the transformations from .NET by using the XslTransformation (I think that's it's name) class.
|
|
|
|
|
No, basically it's a scripting language which can transform one xml document into another (text) document. You can get it to output any form of text, plain text, xml, html etc. The transformations won't affect the original file unless you overwrite it. What you may be thinking of is you can link a stylesheet into an xml file (link a css stylesheet into html) and when IE or FF go to display it they try to find the stylesheet and apply the transformation (what it'll normally output is a nice-pretty formatted html version of the xml file so that it's easier to read than a plain xml file).
|
|
|
|
|
Hi
How Can I Run A Form In External Seluotion
|
|
|
|
|
What do you mean by that?
Forms are in projects, projects are in solutions. So, what type of project is the form in? If it is a class library then that's easy to do. You can add a project to many solutions - just add the project the form is in to the solution that you want to use it in and then add the appropriate reference in project that you want to use the form in.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
* Reading: Developer Day 5
Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton
My website
|
|
|
|
|
I Mean That I have tow projects first project Will be the menu witch Call the Other projects ? How Can I Do That My Forms Is Not in one selution or 1 project its destiputed
|
|
|
|
|
Do you mean you want to make a program that will start your other programs? Look at the Process class.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
Hey guys.
What I need to be able to do is write a back end 'renderer' that will give me a looping video in the background, with text over the top, with shadows and all that jazz, but also be able to fade not only the text, but the video as well into black or another set of video and text. The video fading makes me think I should use something unmanaged, such as C++ and DirectX. The front end of my program will be written in C#, .NET 2.0. I'm just not sure what to write my 'back end' with. At the moment I'm researching WPF, but not sure if that fulfills my needs, considering I'm Windows XP based, not vista (as is the computer I am writing this for), which would give it a performance hit.
I am not asking for the specifics of how to implement it (though they would be nice), but more of an overview.
Cheers,
Jacob.
|
|
|
|
|
Manaxter wrote: At the moment I'm researching WPF, but not sure if that fulfills my needs, considering I'm Windows XP based, not vista (as is the computer I am writing this for), which would give it a performance hit.
WPF does not take a performance hit by running on XP, if you're graphics card support's DirectX then rendering by WPF is done by the hardware so no performance hit. If the graphics card is not capable enough then rendering is performed in software.
I would try out the animation & video capabilities in WPF first, you'll be pleasantly suprised as to how easy it might be to accomplish (the performance hit over being partially managed code doing the rendering should be negligible on most modern computers since WPF does use DirectX).
|
|
|
|
|
Thanks Ed. I shall look into this.
Can anyone recommend any resource (a book perhaps) for learning WPF? There is a lot of information out there, I'm not exactly sure where to start.
Jacob.
|
|
|
|
|
Check out fellow CPian's blog at http://joshsmithonwpf.wordpress.com[^] he's reviewed a few books on WPF, bought one on his recommendation and awaiting his latest recommendation to arrive from Amazon. His latest post also points to another site which has a good list of stuff.
|
|
|
|
|
Ok,i have string word = "safdsa"; string word2 = "sdfafds"; string word3 = "asdas";
richTextBox1.AppendText(word + word2 + word3);
And i want word2 to be with different font and cursor.I mean let's say that i do something else with the application and if i decide to move the cursor over the "word2" at some moment,the cursor must be changed and "word2" to be with different font/color.Just like hyperlinks in web pages.How is that achieved in other .Net applications?
|
|
|
|
|
hi ,
The only way , according to me atleast , to do that would be to get the word the mouse pointer is on , and then change the word.
1.You get the position of the mouse by handling the MouseMove and MouseDown events from the richtxtbox.
2.The Richtextbox class has a GetCharIndexFromPosition(Point) method, which takes a point. You can suppy the mouse position there
3.Once you get the char index , use the text property and loop first backward , then forward , till you get a space , that should give you the index positions for the word. If then , the word is the one you're after , select it , and set its font and color.
struct Word<br />
{<br />
public string Text;<br />
public int StartPos;<br />
public int EndPos;<br />
}<br />
Point pt;<br />
int p = richTextBox.GetCharIndexFromPosition(pt);<br />
Word GetWordFromIndex()<br />
{<br />
int i=p;<br />
while(true)<br />
{<br />
if(richtextbox.Text[i--]==' '||i==0) break;<br />
<br />
}<br />
Word wd = new Word();<br />
wd.StartPos = i<br />
i=p;<br />
while(true)<br />
{<br />
if(richtextbox.Text[i++]==' '||i==0) break;<br />
<br />
}<br />
wd.EndPos = i;<br />
wd.Text = richtextbox.Text.Substring(wd.SatartPos , (wd.EndPos-wd.StartPos));<br />
return wd;<br />
}<br />
You could then check if the Word.Text is what you we're looking for , and if it is , you can change the Font by setting the SelectedText property to the text , then changing the selectionFont and SelectionColor properties.
Hope i helped
Gideon
|
|
|
|
|
what you need to do is selecting the apt substring and change its font:
richtextbox.Select(Length);
richtextbox.selectedFont = Font.Bla bla bla
|
|
|
|
|
Hello All,
I have a desktop aaplication in C#.NET 2005 (2.0) which uses the datagridview. In that I have two hyper link column say Edit and Delete . For that I add two column of type Hyperlink.
Now I want to merge them in a single column like Action is the colmn name and Edit link and Delete Link .. Like Belove Diagram
I have this...
-----------------------
EmpCode | Edit | Delete
------------------------
1 | Edit | Delete
2 | Edit | Delete
I want this...
------------------
EmpCode | Action
-------------------
1 | Edit Delete
2 | Edit Delete
How I Can do that...?
Regards
Pankaj Joshi
|
|
|
|
|
my apologies. i didnt catch that part on a desktop application.
-- modified at 8:16 Saturday 16th June, 2007
|
|
|
|
|
Sir I allready Mention This is not an ASP.NET Project this is Desktop Application
And also I don't use Any Datasource... I Add Lines one by one Using DataReader
into the datagridview rows and cells.
Regards
Pankaj Joshi
|
|
|
|
|
You can still try his first suggestion.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
Hello All,
I Have combo which have it'd dropdown style = dropdownlist. i.e. no body can
enter the data in it. I add some values in it on the folrm load like ....
cmbQ.Items.Clear();
cmbQ.Items.Add("A");
cmbQ.Items.Add("B");
cmbQ.Items.Add("C");
cmbQ.SelectedIndex = 0;
that means After Form Load the displayed value in cmbQ = A. Right.
Now my Problem ...
If save the values in database using cmbQ.text that means either A,B or C it is save.
But suppose the saved value is C.
when user open form again in edit mode, I want to display the selected values in cmbQ should be C.
How I can Do that...?
Remeber I Don't use DisplayMember, ValueMember property bcoz the ABC values are hardcoded.
I just to show it.
I allready tried
SelectedText
SelectedIndex
Text
SelectedValue
But unable to get desire output...?
I also Change the dropdown style before assign the values like
cmbQ.DropDownStyle = ComboBoxStyle.Simple;
cmbQ.SelectedText = ObjDS.Tables["Version"].Rows[0]["Version"].ToString();
cmbQ.Refresh();
cmbQ.DropDownStyle = ComboBoxStyle.DropDownList;
But Unable To Get Desire Output.
Please Help
-- modified at 4:47 Saturday 16th June, 2007
Regards
Pankaj Joshi
|
|
|
|