Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
jimoomba
Yak Posting Veteran
90 Posts |
Posted - 2012-04-26 : 04:09:18
|
| Hi All,Iam having the below xml format:DECLARE @xml XMLSELECT @xml = '<?xml version="1.0" encoding="UTF-8"?><Page xlink:title="PDU1A-1" ><Item v="481.90" l="PDU1A-1 Volt AB" h="23264"/><Item v="485.30" l="PDU1A-1 Volt BC" h="23265"/><Item v="482.60" l="PDU1A-1 Volt CA" h="23266"/><Item v="205.30" l="PDU1A-1 Volt AN" h="23267"/><Item v="205.80" l="PDU1A-1 Volt BN" h="24130"/><Item v="208.10" l="PDU1A-1 Volt CN" h="24131"/></Page>'when iam trying to reteieve the data using the below query, iam getting the xml parsing error as "XML parsing: line 2, character 29, undeclared prefix"SELECT x.v.value('@v[1]', 'VARCHAR(100)') AS [ID], x.v.value('@l[1]', 'VARCHAR(100)') AS [Text], x.v.value('@h[1]', 'VARCHAR(100)') AS [Text]FROM @xml.nodes('/Page/Item') x(v)kindly help me on the samerams |
|
|
jimoomba
Yak Posting Veteran
90 Posts |
Posted - 2012-04-26 : 07:01:48
|
| i have got the output guys..thanks for all your supportrams |
 |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-04-26 : 07:10:20
|
It is looking for the namespace xlink and not finding it. Is that your entire XML, or is there a part somewhere above it that declares the namespace?If this is your entire XML, do one of the following:a) remove the part that reads xlink:title="PDU1A-1" changing it to:DECLARE @xml XMLSELECT @xml = '<?xml version="1.0" encoding="UTF-8"?><Page><Item v="481.90" l="PDU1A-1 Volt AB" h="23264"/> b) If you will be using the namespace somewhere down the line, declare the namespace - for exampe:<Page xmlns:xlink="uri:SomeNamespaceURI" xlink:title="PDU1A-1" > |
 |
|
|
jimoomba
Yak Posting Veteran
90 Posts |
Posted - 2012-04-27 : 02:08:40
|
| thanks for your reply sunitha, i got this sorted out using with xmlnamespaces()rams |
 |
|
|
|
|
|
|
|