473,396 Members | 2,154 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,396 software developers and data experts.

XPath with ADO XML

All,

I am tearing my hair out on this one. I've checked Google and the
newsgroups, and can't seem to solve it...

My problem:

I have an XML document that I pass to another function with an XPath
query (note I may be using the wrong terminology - I don't use XML very
often). The function then uses that XPath query with SelectSingleNode
to get some details out of the XML document (effectively an ID for the
document).

My document is an XML representation of an ADO recordset. The query is
trying to get the FPTAdviserID out of it. Note that I have to use
SelectSingleNode (or more accurately, the code I am calling uses it for
tons of other XML files, so I don't want to fiddle with it
unnecessarily).

Code I have tried includes stuff like:

Dim x As New XmlDocument()

x.Load("d:\current\bin\Adviser.XML")
MsgBox(x.SelectSingleNode("\\xml\rs:data\z:row\@FP TAdviserID").Value)

MsgBox(x.SelectSingleNode("xml\rs:data\z:row\@FPTA dviserID").Value)
MsgBox(x.SelectSingleNode("\\xml\rs:data\z:row").V alue)
MsgBox(x.SelectSingleNode("xml\rs\z").Value)
MsgBox(x.SelectSingleNode("xml\data\row").Value)

MsgBox(x.DocumentElement.SelectSingleNode("rs:data \z:row").Value)

MsgBox(x.DocumentElement.SelectSingleNode("rs:data \z:row").Value)

It just doesn't seem to like the 'rs:data' thing. There is stuff on
Google about namespaces for XML DOMs, but all the tips seem to relate
to the COM XML components, and I can't find matching suggestions for
VB.NET.

Can anyone provide the correct parameters for SelectSingleNode (note
again that I need to use SelectSingleNode)?

My XML is as follows:
<xml xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882'
xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882'
xmlns:rs='urn:schemas-microsoft-com:rowset'
xmlns:z='#RowsetSchema'>
<s:Schema id='RowsetSchema'>
<s:ElementType name='row' content='eltOnly' rs:updatable='true'>
<s:AttributeType name='ABN' rs:number='1' rs:nullable='true'
rs:maydefer='true' rs:write='true'
rs:basetable='Advisers'
rs:basecolumn='AdviserID' rs:autoincrement='true'>
<s:datatype dt:type='string' dt:maxLength='11'/>
</s:AttributeType>
<s:AttributeType name='Address1' rs:number='2'
rs:nullable='true'
rs:maydefer='true' rs:write='true'
rs:basetable='Advisers'
rs:basecolumn='SaveDateTime'>
<s:datatype dt:type='string' dt:maxLength='60'/>
</s:AttributeType>
<s:AttributeType name='Address2' rs:number='3'
rs:nullable='true'
rs:maydefer='true' rs:write='true'
rs:basetable='Advisers'
rs:basecolumn='Company'>
<s:datatype dt:type='string' dt:maxLength='60'/>
</s:AttributeType>
<s:AttributeType name='Address3' rs:number='4'
rs:nullable='true'
rs:maydefer='true' rs:write='true'
rs:basetable='Advisers'
rs:basecolumn='Address1'>
<s:datatype dt:type='string' dt:maxLength='60'/>
</s:AttributeType>
<s:AttributeType name='AdviserID' rs:number='5'
rs:maydefer='true'
rs:writeunknown='true' rs:basetable='Advisers'
rs:basecolumn='Address2'>
<s:datatype dt:type='int' dt:maxLength='4'
rs:precision='10'
rs:fixedlength='true'/>
</s:AttributeType>
<s:AttributeType name='Company' rs:number='6'
rs:nullable='true'
rs:maydefer='true' rs:write='true'
rs:basetable='Advisers'
rs:basecolumn='Address3'>
<s:datatype dt:type='string' dt:maxLength='50'/>
</s:AttributeType>
<s:AttributeType name='Email' rs:number='7'
rs:nullable='true'
rs:maydefer='true' rs:write='true'
rs:basetable='Advisers'
rs:basecolumn='Suburb'>
<s:datatype dt:type='string' dt:maxLength='100'/>
</s:AttributeType>
<s:AttributeType name='Fax' rs:number='8' rs:nullable='true'
rs:maydefer='true' rs:write='true'
rs:basetable='Advisers'
rs:basecolumn='State'>
<s:datatype dt:type='string' dt:maxLength='25'/>
</s:AttributeType>
<s:AttributeType name='FPTAdviserID' rs:number='9'
rs:nullable='true'
rs:maydefer='true' rs:write='true'
rs:basetable='Advisers'
rs:basecolumn='Postcode'>
<s:datatype dt:type='string' dt:maxLength='20'/>
</s:AttributeType>
<s:AttributeType name='Phone' rs:number='10'
rs:nullable='true'
rs:maydefer='true' rs:write='true'
rs:basetable='Advisers'
rs:basecolumn='Phone'>
<s:datatype dt:type='string' dt:maxLength='25'/>
</s:AttributeType>
<s:AttributeType name='Postcode' rs:number='11'
rs:nullable='true'
rs:maydefer='true' rs:write='true'
rs:basetable='Advisers'
rs:basecolumn='Fax'>
<s:datatype dt:type='string' dt:maxLength='4'/>
</s:AttributeType>
<s:AttributeType name='SaveDateTime' rs:number='12'
rs:nullable='true' rs:maydefer='true' rs:write='true'
rs:basetable='Advisers' rs:basecolumn='Email'>
<s:datatype dt:type='dateTime' rs:dbtype='variantdate'
dt:maxLength='16' rs:fixedlength='true'/>
</s:AttributeType>
<s:AttributeType name='State' rs:number='13'
rs:nullable='true'
rs:maydefer='true' rs:write='true'
rs:basetable='Advisers'
rs:basecolumn='ABN'>
<s:datatype dt:type='string' dt:maxLength='3'/>
</s:AttributeType>
<s:AttributeType name='Suburb' rs:number='14'
rs:nullable='true'
rs:maydefer='true' rs:write='true'
rs:basetable='Advisers'
rs:basecolumn='FPTAdviserID'>
<s:datatype dt:type='string' dt:maxLength='20'/>
</s:AttributeType>
<s:extends type='rs:rowbase'/>
</s:ElementType>
</s:Schema>
<rs:data>
<z:row ABN='1234987' Address1='' Address2='asdasd' Address3=''
AdviserID='2' Company='Da;lk' Email='' Fax=''
FPTAdviserID='1000100000001'
Phone='' Postcode='' SaveDateTime='2005-10-17T16:45:59'
State='' Suburb=''/>
</rs:data>
</xml>

Thanks
Matthew

Nov 21 '05 #1
1 1597
MJwills,

Feel free to post to this newsgroup, however I see *seldom* answers in depth
about XPath in this newsgroup. In your case I would ask it in at least as
well in a more XML *document* related newsgroup.

If I process a XML document (not a dataset) in VBNet I have used in past the
document load, however now I would probably use the xmlreader/xmltextreader.

http://msdn.microsoft.com/library/de...classtopic.asp

This one would be my choise the xmltextreader

http://msdn.microsoft.com/library/de...classtopic.asp

I hope this helps,

Cor
Nov 21 '05 #2

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

Similar topics

1
by: bdinmstig | last post by:
I refined my attempt a little further, and the following code does seem to work, however it has 2 major problems: 1. Very limited support for XPath features Basic paths are supported for...
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
4
by: Son KwonNam | last post by:
In XSLT, is this possible to get value from xml using XPath which is in XSLT variable? I mean XPath strings can be dynamic while XSL Transforming. If possible, How?? Because I'm not a...
5
by: laks | last post by:
Hi I have the following xsl stmt. <xsl:for-each select="JOB_POSTINGS/JOB_POSTING \"> <xsl:sort select="JOB_TITLE" order="ascending"/> This works fine when I use it. But when using multiple...
18
by: jacksu | last post by:
I have a simple program to run xpath with xerces 1_2_7 XPathFactory factory = XPathFactory.newInstance(); XPath xPath = factory.newXPath(); XPathExpression xp = xPath.compile(strXpr);...
9
by: David Thielen | last post by:
Hi; I am sure I am missing something here but I cannot figure it out. Below I have a program and I cannot figure out why the xpath selects that throw an exception fail. From what I know they...
5
by: Gnic | last post by:
Hi , I have an XmlDocument instance, I want to find a node in the xml, but I don't know it's path until runtime, for example <aaa> <bbb name="x"/> <aaa attr="y"> <ccc>sometext</ccc> </aaa>
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"...
3
by: Jason Mobarak | last post by:
Hello -- I'm attempting to get a handle on how to do xpath queries with System.Xml -- so far the biggest hurdle has been how to deal with a default namespace. If I use the test xml: <?xml...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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
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
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,...
0
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...

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.