Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old March 11th, 2007, 12:44 PM
Registered User
Join Date: Mar 2007
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

Old March 11th, 2007, 01:05 PM
joefawcett's Avatar
Wrox Author
Join Date: Jun 2003
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)
Old March 11th, 2007, 03:20 PM
mhkay's Avatar
Wrox Author
Join Date: Apr 2004
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

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

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