473,796 Members | 2,376 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multiple xpathexpression with Namespacemanage r

Hi

Have created an xml document with an xmltextwriter with a namespace, so it
can be validated against an xsd schema.
Later in my application, I want to extract values from the xml and am using
xpathexpression .

Because I have a namespace in the xml, I have to use the xmlNameSpaceMan ager
and comile an xpathquery as below:

objXMLXPathNav = objXMLXPathDocu ment.CreateNavi gator()

'//Add namespace manager
'Dim objExpr As XPathExpression =
objXMLXPathNav. Compile("ns1:ro ot/ns1:element1")
'Dim objNamespaces As XmlNamespaceMan ager = New
XmlNamespaceMan ager(New NameTable)
'objNamespaces. AddNamespace("n s1",
"http://tempuri.org/myXSD.xsd")
'objExpr.SetCon text(objNamespa ces)

Dim objXPathNodeIte rator As XPathNodeIterat or = objXMLXPathNav. Select(objExpr)
While (objXPathNodeIt erator.MoveNext ())
intValue = CInt(objXPathNo deIterator.Curr ent.Value())
End While

This works fine for finding one node, but I want to match a further 6
different nodes, which are above and below the first node I select

I can't find any examples where multiple xpathexpression s are used.

Do I have to re-create the whole process to create a new xpathexpression
every time, or is there an easier way?

Thanks
Nov 17 '05 #1
0 1055

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

Similar topics

5
1672
by: mono | last post by:
Hello, I have a collection of XML strings and want to find those that match a given XPath expression. I see lots of stuff to support evaluating the same expression against different nodes in a single document but as far as I can see, if I want to evaluate the expression against different docs, I have to recreate it everytime.
2
2770
by: Steve Taylor | last post by:
Is there some reason why I shouldn't be able to use the same XPathExpression simultaneously in multiple iterations? The test below illustrates the problem. It seems that creating two XPathNodeIterators with the same expression creates a coupling between the iterators so they always point to the same position. Anyone care to comment? public void ReuseCompiledExpr() { XmlDocument doc = new XmlDocument();
4
1160
by: gajba | last post by:
Hi, from an XML beginner.. I have an XML like the one below: <root> <vendor name="Microsoft"> <!-- additional sub-tags and items --> </vendor> <vendor name="Sun"> <!-- additional sub-tags and items -->
4
4511
by: viditmittal | last post by:
hi, i have a xml file <root> <Type /> <Description /> <Category /> <employee > <id>3</id>
4
4416
by: Vishy | last post by:
Hi I'm trying to read xml file with namespacemanager; it seems that it adds up a namespace if there is none; How can avoid this? so <ID>00589</ID> becomes <Id xmlns=\"x-schema:#Schema1\">00589</Id> Thanks
0
1400
by: Philipp Schumann | last post by:
Hi there, don't know whether anyone ran into this issue formerly (in .NET 1.0). I have an XML document with a default namespace (indicating the target namespace of the XML Schema used to validate the document): <ObjectIndex xmlns="http://ref.devlink.net/opal/runtime/ObjectBaseSchema
0
1224
by: Martin | last post by:
Hi, I am using xmldocument.selectsinglenode to query an xml document. This works perfectly when the document to be queried has no namespace, however as some as i put a namespace in then null is returned from selectsinglenode. I think I am not creating the namespace manager correctly. I have created a very small sample piece of code (see below) that
1
5071
by: Bruce Sandeman | last post by:
Hi, Is anyone able to help me? I have the following code and when I try to create an XPathNavigator object it keeps returning null. any cunning ideas? private void loadXMLDoc(String xml) { xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xml); namespaceManager = new
2
2325
by: darrel | last post by:
I have an XML file that looks like this: <Counties> <County> <District>2</District> <CountyName>Palm</CountyName> </County> <County> <District>3</District> <CountyName>McCarthy</CountyName>
0
9680
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
9528
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
10455
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
10228
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...
0
6788
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
5441
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...
0
5573
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4116
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
2
3731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.