Dear all
i Wonder how can i edit a node property (in C# not by hand :) )
i have the follwing XMl file (hibernate.cfg. xml)
[html]<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhib ernate-configuration-2.0" >
<session-factory name="NHibernat e.Test">
<!-- properties -->
<property name="connectio n.provider">NHi bernate.Connect ion.DriverConne ctionProvider</property>
<property name="connectio n.driver_class" >NHibernate.Dri ver.OracleDataC lientDriver</property>
<property name="connectio n.connection_st ring">User ID=th;password= manager;Data Source=th02;Per sist Security Info=False</property>
<property name="show_sql" >true</property>
<property name="dialect"> NHibernate.Dial ect.Oracle9Dial ect</property>
<property name="use_outer _join">true</property>
<property name="query.sub stitutions">tru e 1, false 0, yes 'Y', no 'N'</property>
<!-- mapping files -->
<mapping assembly="Pla.P er"/>
<mapping assembly="Int.P er"/>
<mapping assembly="Pen.M ap"/>
</session-factory>
</hibernate-configuration>[/html]
i want to change dynamically the connection.conn ection_string string property
thanks alot
ron NOTE: Please add code or html tags to samples. Thanks, moderator.
5 17779
OK
for note this is the code which i wrote - XmlDocument xmlDoc = new XmlDocument();
-
-
xmlDoc.Load("hibernate.cfg.xml");
-
-
XmlNamespaceManager nm = new XmlNamespaceManager(xmlDoc.NameTable);
-
-
nm.AddNamespace("HC", "urn:nhibernate-configuration-2.0");
-
-
XmlNode node = xmlDoc.SelectSingleNode("//HC:session-factory[@name='NHibernate.Test']/HC:Property[@name='connection.connection_string']",nm);
-
-
node.InnerText = "New Value";
-
-
xmlDoc.Save("hibernate.cfg.xml");
but i have all the time node = null that means that something in the Xpath Query is incorrect
Ron
Welcome to TheScripts TSDN...
You may use XMLDocument class.
See these links: Manipulate XML data with XPath and XmlDocument
and Modify XML Data by Using DOM in .NET Framework
You need to use SelectSingleNod e() method and to update the InnerText property of the selected XmlNode. Then call the Save() method.
I hope to succeed. Otherwise, let us know.
use property, not Property, to look like this: - xmlDoc.SelectSingleNode("//HC:session-factory[@name='NHibernate.Test']/HC:property[@name='connection.connection_string']",nm);
-
Wow - you are amazing - how could i resolve this problem????!?!! ? (you cant debug Xpath)
i will recommand you to be an XML MVP :)
use property, not Property, to look like this: - xmlDoc.SelectSingleNode("//HC:session-factory[@name='NHibernate.Test']/HC:property[@name='connection.connection_string']",nm);
-
Thanks,
You're welcome.
God bless you.
Dorin.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Alex Sab |
last post by:
Hi,
I am having trouble describing in a schema that elements can be
mandatory in one part and not mandatory in another part of the xml
document. Here is a sample xml file
<Model:Templates>
<Node:Template Node:nodeId="nodeID">
<Node:Name Node:Comment="">Name</Node:Name>
<Node:Name2 Node:Comment="">Name</Node:Name2>
...
|
by: Mr. x |
last post by:
Hello,
Suppose I have a table like this :
<table width = "580">
<tr align = "right" width = 760>
<td id = "current_page_inner">
<font size="4" color="lightgreen" face="arial"><b><i>
abc
</i></b>
|
by: Richard Trahan |
last post by:
(This is a repost -- the original got tucked away into an old thread
because I used the same Subject name.)
I'm trying to change the document title to add an asterisk when the
document becomes "dirty", as seen on editor applications.
I use the code below. Venkman shows that everything looks as expected.
The last line is for the debugger, which indicates that the title is
changed, but it does not display.
|
by: Keith Smith |
last post by:
How can I change the background IMAGE (not just color) of a CELL in a table?
I know that I can do this using CSS, but I really need to be able to do it
using JavaScript. Anyone know how?
Must be able to change the image for each cell - not the whole table.
Please help.
|
by: kevin |
last post by:
I would like to remember the state of the nodes after the treeview gets
disposed, but not necessarily after the app terminates so I don't need a disk
file. I was thinking about using the tag property, but I am already using it,
so then I though about making a custom treeiew using inheritance and adding
another tag type property? Any clues?
kevin
| |
by: XML newbie: Urgent pls help! |
last post by:
HI,
I am working on VB.Net.My program connects to the remote host, once the
login values are verified, it sends the SessionID. My problem is Although in
"Logindom" variable( in the Auto window), I see it has child nodes, but nodes
= Nothing.. Since, I need to copy the value of SessionID in my next function,
how can I read the value of Node. If I do, LoginDom.InnerText, then I
get"SuccessSessionID", if there is no way to get node value...
|
by: Kavitha Sudhershan |
last post by:
hi,
i wanna read the node values from xml. As per my code i can read the node values in first child node and for the next node am not able to read the node values. pls help me.
i'll paste the code below:
Sub readfile()
objxmldom.async = False
objxmldom.Load ("D:\CRT\rules\AQUA.xml")
|
by: Guzeppi |
last post by:
Hi,
i'm using linq to load an xml structure into my classes. the xml consists of
the same node nested for multiple levels e.g.
<node id="node_id01" name="node 01">
<node id="node_id0101" name="node 01 01">
<node id="node_id010101" name="node 01 01 01">
<node id="node_id01010101" name="node 01 01 01 01">
<node id="node_id0101010101" name="node 01 01 01 01 01">
|
by: =?Utf-8?B?bWFib25k?= |
last post by:
I'm using a treeview control.
One parent node, several child nodes, several grandchild nodes.
Each of the nodes has a checkbox.
My question, when the user changes the check value of one of the grandchild
nodes to true how do I automatically change that node's parent to check-true
and so on up the tree.....and in reverse if the parent is changed to
check-false how do I cascade that down to each of the child nodes and their
child nodes.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |