473,395 Members | 1,460 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Xpath on VS2005 file

I can't seem to get an xpath expression proper to get the references out of
the *.vbproj project file in VS2005.

the project is loaded into an XMLDocument

_dom = new xmldocument
_dom.load(pathToMyProjectFile)

dim myNodeList as XMLNodeList
myNodeList = _dom.selectNodes("some xpath expression that returns the
references"). ????

I have tried a lot of things but I just don't seem to get it. MyNodeList has
zero elements in it.

Thanks in advance,
jff

Nov 27 '05 #1
2 1894
Hi,

"Jeff Jarrell" <jj************@yahoo.com> wrote in message
news:ef**************@TK2MSFTNGP14.phx.gbl...
I can't seem to get an xpath expression proper to get the references out of
the *.vbproj project file in VS2005.

the project is loaded into an XMLDocument

_dom = new xmldocument
_dom.load(pathToMyProjectFile)

dim myNodeList as XMLNodeList
myNodeList = _dom.selectNodes("some xpath expression that returns the
references"). ????
After having a look at the vb project file (VB2005Express/VC2005Beta2), it
looks like the root node has a default namespace (see xmlns="..." ). A
default namespace applies to the element and all child elements. (Child
elements can override the default namespace though.)

The path as in XPath, must be fully qualified, even when a namespace is a
default one.

Dim xdoc As New XmlDocument
xdoc.Load(pathToMyProjectFile)

' get default namespace and create a prefix for it
Dim xmlnsmgr As New XmlNamespaceManager(xdoc.NameTable)
xmlnsmgr.AddNamespace("d", xdoc.DocumentElement.NamespaceURI)

Dim nodes As XmlNodeList =
xdoc.SelectNodes("/d:Project/d:ItemGroup/d:Reference", xmlnsmgr)
For Each node As XmlNode In nodes
Console.WriteLine(node.Attributes("Include").Value )
Next

HTH,
Greetings


I have tried a lot of things but I just don't seem to get it. MyNodeList
has zero elements in it.

Thanks in advance,
jff

Nov 27 '05 #2
Aha... Thank you.

jeff

"Bart Mermuys" <bm*************@hotmail.com> wrote in message
news:e9**************@TK2MSFTNGP11.phx.gbl...
Hi,

"Jeff Jarrell" <jj************@yahoo.com> wrote in message
news:ef**************@TK2MSFTNGP14.phx.gbl...
I can't seem to get an xpath expression proper to get the references out
of the *.vbproj project file in VS2005.

the project is loaded into an XMLDocument

_dom = new xmldocument
_dom.load(pathToMyProjectFile)

dim myNodeList as XMLNodeList
myNodeList = _dom.selectNodes("some xpath expression that returns the
references"). ????


After having a look at the vb project file (VB2005Express/VC2005Beta2), it
looks like the root node has a default namespace (see xmlns="..." ). A
default namespace applies to the element and all child elements. (Child
elements can override the default namespace though.)

The path as in XPath, must be fully qualified, even when a namespace is a
default one.

Dim xdoc As New XmlDocument
xdoc.Load(pathToMyProjectFile)

' get default namespace and create a prefix for it
Dim xmlnsmgr As New XmlNamespaceManager(xdoc.NameTable)
xmlnsmgr.AddNamespace("d", xdoc.DocumentElement.NamespaceURI)

Dim nodes As XmlNodeList =
xdoc.SelectNodes("/d:Project/d:ItemGroup/d:Reference", xmlnsmgr)
For Each node As XmlNode In nodes
Console.WriteLine(node.Attributes("Include").Value )
Next

HTH,
Greetings


I have tried a lot of things but I just don't seem to get it. MyNodeList
has zero elements in it.

Thanks in advance,
jff


Nov 27 '05 #3

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

Similar topics

0
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
1
by: Phoebian | last post by:
Hi all, Here is a little concept problem, and I need some guideline. I am currently developing a application which delivers XML files. I want then to sequentially perform some actions on...
4
by: Gismo | last post by:
I have got file raport.rld which is an XML file generated by MS Reporting Services. The problem is: in this file are tags from two different namespaces ...
2
by: trond | last post by:
Hello all, I am building a personal web site in VS2005 as a kind of learing project for myself, so forgive me if this is a novice question. I am planning to use an XML file called...
3
by: werD | last post by:
Hello I have an xml document that im currently using a forward only .net repeater on and using some xpath queries to display the data The xml is quite simple <?xml version="1.0"...
2
by: Bilal | last post by:
Hello, I'm stuck on this problem for quite some time and hope somebody would be able to guide me. Basically, I need to populate a large number of "template" XML files which have all...
3
by: abcd_68 | last post by:
Hi there, I'm using, for the first time, the JDK1.5 Xpath API. I need to find elements in a Hibernate-generated .hbm.xml file. These files come with a <!DOCTYPE header mentioning a remote URL....
5
by: rcronk | last post by:
I'm new to C#/.NET. I am writing some C#/.NET (2.0) classes that will allow someone to get and set values in an XML file using an XPath to point to the location of that data. It's more complicated...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
Oralloy
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.