473,383 Members | 1,792 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,383 software developers and data experts.

How to use XPath to read identical elements with different Text Values

17
Hi,

I have a XML, which I don't have any choice to modify the structure of it.


<MemberAddress>
<xAL:FreeTextAddress>
<xAL:AddressLine>123 Street Name</xAL:AddressLine>
<xAL:AddressLine>Suburb, City</xAL:AddressLine>
</xAL:FreeTextAddress>
<xAL:Country>
<xAL:Name>New Zealand</xAL:Name>
</xAL:Country>
<xAL:PostCode>
<xAL:Identifier>6011</xAL:Identifier>
</xAL:PostCode>
</MemberAddress>

I would like to write a stored procedure with XPath to read 2 addressLines in SQL Server.

AddressLine1 varchar(30) 'n:MemberAddress/xAL:FreeTextAddress/xAL:AddressLine',
AddressLine2 varchar(30) 'n:MemberAddress/xAL:FreeTextAddress/xAL:AddressLine',

The code above only give me "123 Street Name" for both fields. Just like to know how can I get xPath to read "Suburb, City" for the second field?

Thanks
Apr 1 '07 #1
2 1446
yingwen
17
I have found out the answer by myself. Thanks.

Just use

AddressLine1 varchar(30) 'child::n:MemberAddress/xAL:FreeTextAddress/xAL:AddressLine[position() = 1]',
AddressLine2 varchar(30) 'child::n:MemberAddress/xAL:FreeTextAddress/xAL:AddressLine[position() = 2]',
Apr 1 '07 #2
dorinbogdan
839 Expert 512MB
Ok, glad to hear that.

Thank you for replying the solution.

God bless you,
Dorin.
Apr 2 '07 #3

Sign in to post your reply or Sign up for a free account.

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...
5
by: Tom Alsberg | last post by:
Hi there... I'm recently trying to get a bit acquainted with XML Schemas and XSL. Now, I have a few questions about XSL stylesheets and templates: * Is there a way to "enter" a child element...
2
by: ajkadri | last post by:
Hi folks, I am new to XML. I came across the following location path expressions: (i) /*/* (ii) /quotelist/quotation can anyone explain me the nodeset for the above two path...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.