473,811 Members | 3,123 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Anyone familiar with using XPath in c#

Hi,

In my first attempt I'm confused why I'm not getting a single nodes value
but instead getting a ton of extra values that are in the document but
located before the value I wish to get. I'm passing in a csproj file and
looking to extract the OutputType value, which is a single value in a group
of nodes. The root is Project and there are several PropertyGroup nodes
however only the first one contains the value Outputtype so I'm not sure if
that makes a difference.

start snippet
new XPathDocument(_ currentFile.Ful lName);
// Create a navigator to query with XPath.
nav = docNav.CreateNa vigator();
strExpression = "/Project/PropertyGroup/OutputType";
XPathExpression xpress = nav.Compile(str Expression);
Console.WriteLi ne("OutputType : {0}",
nav.Select(strE xpression).Curr ent.Value );

end snippet
This is what the output looks like

OutputType :
DebugAnyCPU8.0. 507272.0{106C49 F4-4260-4A70-A362-84AF2DA95766}Ex ePropertiesWelc omeEmailWelcome Emailtruefullfa lsebin\Debug\DE BUG
;TRACEprom
pt4pdbonlytrueb in\Release\TRAC Eprompt4False.. \..\Vendor\DLL\ Microsoft.Appli cationBlocks.Da ta.dllFalse..\. .\Vendor\DLL\Mi crosoft.Applica tionBlocks.Exce
ptionManagement .dllFalse..\..\ SPE_1_1\SPEComp onents\obj\Debu g\SPE.Component s.dll

That is every value in jsut /Project/PropertyGroup jammed together when all
I want is the value Exe from the node /Project/PropertyGroup/OutputType

Thanks for the help

Mar 23 '07 #1
0 826

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

Similar topics

6
5990
by: 0wl | last post by:
Hi, I am trying to get the value of child from xmlstr = """<p:root xmlns:p="http://tempuri.org/string"><p:child DataType="String">Hellpppp</p:child></p:root>""" using doc=parseString(xmlstr) nodeList = xml.xpath.Evaluate("/p:root/p:child/text()", doc)
5
7423
by: Clifford W. Racz | last post by:
Has anyone solved the issue of translating lists in Word 2003 (WordML) into xHTML? I have been trying to get the nested table code for my XSLT to work for a while now, with no way to get the collection that I need. To begin, I am using xsltproc that conmes with Cygwin as my processor. I have no particular affinity to this processor except that it is open source and standards compliant. I don't like M$, but if using a M$ processing...
2
1401
by: Derek Fountain | last post by:
I've spent the last few days tinkering with DOM trees and the DOM API. A couple of years back I wrote a fairly complex application which found the data it required using this nextSibling, firstChild, sort of navigation. I recall the development experience wasn't a terribly happy one, and I have always presumed that XPATH was largely invented to get past all this mucking about. So it occurs to me to ask: do people still use the original...
2
2882
by: ree32 | last post by:
When I import an xml document in Visual studio and Genereate as schema from it, and create a dataset from it, it adds this line into to the root element of my xml file - "xmlns="http://tempuri.org/nameOfRoot.xsd" I have no idea what its pointing to & what is tempuri.org? So when this tag is in my xml tag my xpath query never works. But when I delete it work fine.
0
9734
marktang
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...
0
9607
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,...
0
10662
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, 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...
0
10398
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10416
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9215
agi2029
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...
1
7676
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6897
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5567
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 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.