473,587 Members | 2,263 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need XPath help

Hi,

I am trying to use an XmlDocument object to manipulate the default database
instance node of the enterprise template library dataConfigurati on section
from a custom installer step:

<?xml version="1.0" encoding="utf-8"?>
<dataConfigurat ion>
<xmlSerializerS ection
type="Microsoft .Practices.Ente rpriseLibrary.D ata.Configurati on.DatabaseSett ings,
Microsoft.Pract ices.Enterprise Library.Data, Version=1.1.0.0 , Culture=neutral ,
PublicKeyToken= null">
<enterpriseLibr ary.databaseSet tings
xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
defaultInstance ="AdessoOdbc "
xmlns="http://www.microsoft.c om/practices/enterpriselibra ry/08-31-2004/data">
<databaseType s>

I have tried several XPath queries but I am not having any luck fetching the
"defaultInstanc e" attribute - xpath seems to be unhappy about the '.' in the
"enterpriseLibr ary.databaseSet tings" node name. For example this code:

XmlNode node =
xml.SelectSingl eNode("dataConf iguration/xmlSerializerSe ction/enterpriseLibra ry.databaseSett ings");

does NOT return "enterpriseLibr ary.databaseSet tings" node - it returns null.
Any ideas on how I can get to the defaultInstance attribute?
Nov 17 '05 #1
2 1545
Richard wrote:
Hi,

I am trying to use an XmlDocument object to manipulate the default database
instance node of the enterprise template library dataConfigurati on section
from a custom installer step:

<?xml version="1.0" encoding="utf-8"?>
<dataConfigurat ion>
<xmlSerializerS ection
type="Microsoft .Practices.Ente rpriseLibrary.D ata.Configurati on.DatabaseSett ings,
Microsoft.Pract ices.Enterprise Library.Data, Version=1.1.0.0 , Culture=neutral ,
PublicKeyToken= null">
<enterpriseLibr ary.databaseSet tings
xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
defaultInstance ="AdessoOdbc "
xmlns="http://www.microsoft.c om/practices/enterpriselibra ry/08-31-2004/data">
<databaseType s>

I have tried several XPath queries but I am not having any luck fetching the
"defaultInstanc e" attribute - xpath seems to be unhappy about the '.' in the
"enterpriseLibr ary.databaseSet tings" node name. For example this code:

XmlNode node =
xml.SelectSingl eNode("dataConf iguration/xmlSerializerSe ction/enterpriseLibra ry.databaseSett ings");

does NOT return "enterpriseLibr ary.databaseSet tings" node - it returns null.
Any ideas on how I can get to the defaultInstance attribute?

Hi,

It's not the dot.

The enterpriseLibra ry.databaseSett ings is in a different namespace,
declared by the
xmlns="http://www.microsoft.c om/practices/enterpriselibra ry/08-31-2004/data"
attribute.

You have to use a nametable/namespacemanage r to assign a prefix for this
namespace, after that you can use xpath queries it like this:

XmlNode node =
xml.SelectSingl eNode("dataConf iguration/xmlSerializerSe ction/myprefix:enterp riseLibrary.dat abaseSettings") ;

If you need help with the C# part, let me know...

Luck, Wiebe
Nov 17 '05 #2
Hi,
Will this be the right way to do this? :

XmlTextReader xreader = new XmlTextReader( xmlfilename );
XmlNamespaceMan ager nsm = new XmlNamespaceMan ager(xreader.Na meTable );
nsm.AddNamespac e("abc",
"http://www.microsoft.c om/practices/enterpriselibra ry/08-31-2004/data");
XmlNode node =
doc.DocumentEle ment.SelectSing leNode("xmlSeri alizerSection/abc:enterpriseL ib
rary.databaseSe ttings", nsm);

and than you can write:

node.Attributes .GetNamedItem(" defaultInstance ").Value

to get the value.

Ab.
http://joehacker.blogspot.com

"Wiebe Tijsma" <wi*********@CA PITALStijsma.co m> wrote in message
news:#4******** *****@tk2msftng p13.phx.gbl...
Richard wrote:
Hi,

I am trying to use an XmlDocument object to manipulate the default database instance node of the enterprise template library dataConfigurati on section from a custom installer step:

<?xml version="1.0" encoding="utf-8"?>
<dataConfigurat ion>
<xmlSerializerS ection
type="Microsoft .Practices.Ente rpriseLibrary.D ata.Configurati on.DatabaseSett i
ngs, Microsoft.Pract ices.Enterprise Library.Data, Version=1.1.0.0 , Culture=neutral , PublicKeyToken= null">
<enterpriseLibr ary.databaseSet tings
xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
defaultInstance ="AdessoOdbc "
xmlns="http://www.microsoft.c om/practices/enterpriselibra ry/08-31-2004/data"
<databaseType s>

I have tried several XPath queries but I am not having any luck fetching
the "defaultInstanc e" attribute - xpath seems to be unhappy about the '.' in the "enterpriseLibr ary.databaseSet tings" node name. For example this code:

XmlNode node =
xml.SelectSingl eNode("dataConf iguration/xmlSerializerSe ction/enterpriseLibra
ry.databaseSett ings");
does NOT return "enterpriseLibr ary.databaseSet tings" node - it returns null. Any ideas on how I can get to the defaultInstance attribute?

Hi,

It's not the dot.

The enterpriseLibra ry.databaseSett ings is in a different namespace,
declared by the

xmlns="http://www.microsoft.c om/practices/enterpriselibra ry/08-31-2004/data" attribute.

You have to use a nametable/namespacemanage r to assign a prefix for this
namespace, after that you can use xpath queries it like this:

XmlNode node =
xml.SelectSingl eNode("dataConf iguration/xmlSerializerSe ction/myprefix:enterp
riseLibrary.dat abaseSettings") ;
If you need help with the C# part, let me know...

Luck, Wiebe

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
6343
by: MegaZone | last post by:
I'm having some issues with PHP DOMXML - in particular the get_elements_by_tagname method. Now, the PGP docs on this are, well, sparse, so maybe I'm just doing something stupid. I thought this method would behave like the 'findnodes' XML method in Perl. Namely that you can pass it an xpath statement and it will find nodes that match:...
0
1913
by: gael.pegliasco | last post by:
Hi, How are you dear and nice helper :) ? I'm trying to test xpath with this simple program : import xml.dom.minidom from xml.xpath.Context import Context import xml.xpath
7
4377
by: Mike Kamermans | last post by:
I hope someone can help me, because what I'm going through at the moment trying to edit XML documents is enough to make me want to never edit XML again. I'm looking for an XML editor that has a few features that you'd expect in any editor, except nearly none of them seem to have: 1 - Search and repalce with Regular Expressions. 2 - ...
2
1646
by: Jaunedeau | last post by:
I have some XML that must look like this : <movies> <movie id="1"> <actor preferredMovieId="1"> <actor preferredMovieId="2"> <actor preferredMovieId="3"> </movie> <movie id="2"> <actor preferredMovieId="2">
2
1399
by: AGB | last post by:
Hi all, I have the following simple XML file. I would like to load all the values in the Name nodes into a drop-down list box: <?xml version="1.0" encoding="utf-8" ?> <OutlineCodeNames> <OutlineCodeName> <UID>23423523</UID> <Name>Contract</Name>
3
1413
by: Shawn | last post by:
Hi. I have an XML file that looks like this: <?xml version="1.0" encoding="utf-16"?> <Transfer> <Config xmlns="http://www.mysite.com/Transfer/"> <site>NY</site> </Config> </Transfer> I'm trying to get the value of "site", but I'm having some trouble with it.
5
2148
by: Chua Wen Ching | last post by:
Hi, I read from this tutorial at codeproject Question A: http://www.codeproject.com/csharp/GsXPathTutorial.asp regarding xpath.. but i try to apply in my situation, and can't get it work...
0
1096
by: Joe | last post by:
Hi Could someone give me a simple explaination of this XSD which is a DataSet with relations The tables are fgFAT,e0,e1,e2,e3 which I have deleted I am trying to make sense of the part below Here is what I am guessing - any help would be appreciated
1
2871
by: jesper_lofgren | last post by:
Hello, i need to help here. I have a xmlnode as you can se below (full xml is in the bottom). I wonder how i can get the values inside the CSammanstallningLista . <CSammanstallning Id="Omrade" DefaultInclude="0"> <Rubrik>Område</Rubrik> <Text>Kallhäll. Fabriksvägen, Hus S, JÄRFÄLLA</Text> </CSammanstallning>
0
8339
jinu1996
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...
0
8220
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5712
isladogs
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...
0
5392
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3840
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...
0
3872
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2347
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1452
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1185
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.