Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XML
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 11th, 2007, 12:44 PM
Registered User
Join Date: Mar 2007
Location: Nantwich, Cheshire, United Kingdom.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default XML Parsing

Firstly before I wade in with my problem I'll introduce myself as I'm new here. I'm an automation software engineer from the UK. There is an ever increasing trend in industry to integrate the automation data requirements with those at the enterprise level. More increasingly we are becomming involved with SQL Server and devloping VB NET front ends for these.

I'm working through an example from Professional VB.NET 2nd Edition. The problem I'm experiencing realates to parsing an XML document. The XML I'm parsing is as follows:

<?xml version="1.0"?>
  <StoredProcedure name="usp_Get_Authors_By_States">
      <Parameter name="@states" size="100" datatype="VarChar" direction="spParamInput" isNullable="True" />

The VB NET code exampl buidls a XPath Query string as follows:

strXPathQuery = "/StoredProcedures/StoredProcedure/[@name='" _
& strSPName & "']/Parameters/Parameter"

Where strSPName is the name of the a Stored Procedure whose parameters I wish the get at.

it's the [@name='" & strSPName & "'] that's causing the problem. There will certainly be more than one StoredProcedure in my XML file so the requirement to pass include a placeholder for any stored procedure in this path query is essential. I am confident that the problem is here because when a remove the reference to the stored procedure in works fine (there is only one in the XML file, for now) i.e.


works fine.

Does anyone have any idea where I'm going wrong

Reply With Quote
  #2 (permalink)  
Old March 11th, 2007, 01:05 PM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts

But you don't say what the problem is...
Does it not return the correct node, no node or what?
What are you passing in for the name of the parameter, try outputting the XPath before calling it to make sure it is correct.


Joe (Microsoft MVP - XML)
Reply With Quote
  #3 (permalink)  
Old March 11th, 2007, 03:20 PM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts

/StoredProcedures/StoredProcedure/[@name='" _ & strSPName & "']

You don't need that "/" before the "[". A predicate is part of a step in a path expression, not a step in its own right.

Michael Kay
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Parsing the xml which is having vikkiefd XML 14 July 28th, 2008 05:21 AM
parsing xml kri_hegde XML 5 July 24th, 2007 11:37 AM
XML parsing denzil_cactus Perl 0 June 11th, 2007 02:34 AM
XML Parsing tgopal Javascript 2 July 27th, 2004 08:54 AM
XML Parsing tgopal .NET Web Services 1 June 15th, 2004 03:25 AM

All times are GMT -4. The time now is 03:46 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.