|
|
show XML schema and values
I have an XML document that looks like the following:
<record>
<Field1>value1</Field1>
<Field2>value2</Field2>
<Field3>value3</Field3>
</record>
What I'm aiming to do is to show the data in a report as in the following
example:
record:
Field1 value1
Field2 value2
Field3 value3
The "Field1-3"-elements can have any name, so I'm trying to get a table that
has in one result column the element name, and in the second column the
element value. How can I achieve this?
I'm primarely interested in the SQL script.
|
|
0
|
|
|
|
Reply
|
Utf
|
4/21/2010 12:20:01 PM |
|
CJ
http://pratchev.blogspot.com/2007/06/shredding-xml-in-sql-server-2005.html
"CJ" <CJ@discussions.microsoft.com> wrote in message
news:212B03EA-BADD-4D0E-A54D-762F6EE4B03C@microsoft.com...
>I have an XML document that looks like the following:
>
> <record>
> <Field1>value1</Field1>
> <Field2>value2</Field2>
> <Field3>value3</Field3>
> </record>
>
> What I'm aiming to do is to show the data in a report as in the following
> example:
>
> record:
> Field1 value1
> Field2 value2
> Field3 value3
>
> The "Field1-3"-elements can have any name, so I'm trying to get a table
> that
> has in one result column the element name, and in the second column the
> element value. How can I achieve this?
>
> I'm primarely interested in the SQL script.
|
|
0
|
|
|
|
Reply
|
Uri
|
4/21/2010 1:37:44 PM
|
|
He only talks about getting the values of an XML document, not about getting
the names. But I saw that I can use Xpath, so here is something that works
for this specific case:
DECLARE @data AS XML
SET @data =
N’
<result>
<Field1>Value1</Field1>
<Field2>Value2</Field2>
<Field3>Value3</Field3>
</result>’
SELECT
result.data.query(‘local-name(.)’) AS ResultName,
resultfield.data.query(‘local-name(.)’).value(‘.’, ‘VARCHAR(MAX)’) AS
FieldName,
resultfield.data.query(‘.’).value(‘.’, ‘VARCHAR(MAX)’) AS FieldValue,
FROM @data.nodes(‘result/.’) AS result(data)
CROSS JOIN @data.nodes(‘result/*’) AS resultfield(data)
And there we are. Using a CROSS JOIN didn't give me any wrong results, so I
guess I can go with that for now.
"Uri Dimant" wrote:
> CJ
> http://pratchev.blogspot.com/2007/06/shredding-xml-in-sql-server-2005.html
>
>
> "CJ" <CJ@discussions.microsoft.com> wrote in message
> news:212B03EA-BADD-4D0E-A54D-762F6EE4B03C@microsoft.com...
> >I have an XML document that looks like the following:
> >
> > <record>
> > <Field1>value1</Field1>
> > <Field2>value2</Field2>
> > <Field3>value3</Field3>
> > </record>
> >
> > What I'm aiming to do is to show the data in a report as in the following
> > example:
> >
> > record:
> > Field1 value1
> > Field2 value2
> > Field3 value3
> >
> > The "Field1-3"-elements can have any name, so I'm trying to get a table
> > that
> > has in one result column the element name, and in the second column the
> > element value. How can I achieve this?
> >
> > I'm primarely interested in the SQL script.
>
>
> .
>
|
|
0
|
|
|
|
Reply
|
Utf
|
4/22/2010 6:43:01 AM
|
|
|
2 Replies
196 Views
(page loaded in 0.043 seconds)
Similiar Articles: Import PickList values - microsoft.public.crmI want users to enter data into the worksheet for import into a database. ... How to change the values in xml for picklist - microsoft.public ... Field missing upon XML import - microsoft.public.access ...... FieldX', but there's no FieldX value (nor ... Loading XML schema into Access 2007 - microsoft ... Import XML data - Excel - Office.com Show All Hide All Before you import XML ... How to find the custom xml tags in a workbook - microsoft.public ...... is I need to find where each of the custom xml ( from the schema ... get 2003 .xlb toolbars and custom macros to show ... XML Deserialize of empty value - microsoft.public ... Different outcome of adding ribbon via xml instead of in a table ...... RS("RibbonName").Value, RS("RibbonXml").Value End If ... rather than opening with my ribbon being on display as ... table ... provided all the restrictions of an XML Schema ... XML capability - microsoft.public.mac.office.excelImport XML data - Excel - Office.com Show All Hide All ... dataset, or possibly, xml data? ... All, I am trying to create an earned value ... OSC) provider XML schema allows ... XML Maps and worksheet protection problem - microsoft.public.excel ...... before protection, unused rows show up as blank data in the xml ... XML Deserialize of empty value - microsoft.public.dotnet ... has a cool ability to take an XML Schema ... Get Access Database Schema - Primary Keys and Indexes - microsoft ...Duplicate values in the index, primary key, or ... Exporting Access schema using XML | TechRepublic In a ... Schema: How do I show all the primary keys in a database? Pulling data from a XML type variable - microsoft.public.windows ...Hide quoted text - > > > > - Show quoted text ... Write-Output of XML value has type format like "System.Xml ... with data How to define typed XML columns using XML schema ... XML vs SQL Server - microsoft.public.dotnet.languages.csharp ...If you want any of that, you need to use XSD (XML Schema ... One part of my copy/paste did not show up well in the ... It does NOT assume that the *values* you supply to the ... HOWTO: data table into acess accdb using vb - microsoft.public ...... Catch ex As Exception MessageBox.Show(ex ... DataRows in the DataTable, set each parameter's value ... Loading XML schema into Access 2007 - microsoft.public ... show XML schema and values SQL Server - SQL Server Discussion List ...I have an XML document that looks like the following: What I am aiming to do is to show the data in a report as in the following example: record: Field1 ... How can I get NULL values to show up in my XML using schemas?How can I get NULL values to show up in my XML using schemas? (24132 Requests) The question comes up of how to get an XML column to appear in a result generated by a ... XML Schema Editor... should be displayed and how the display should be formatted: XML Schema Design - Identity Constraints. Configuring identity constraints (i.e., key/keyref/unique values) is ... Schema.xmlThe Schema.xml file defines the views, forms, toolbar, and ... element specifies the internal name and display name for ... Possible values include the following: RelatedTasks for ... XML Schema Collection, dependent schemas and default attr. values... value definition from the "description" attribute - it will not show ... xml, it rebuilds the xml beased on the internal storage, the xml schema, and the value of ... 7/16/2012 6:35:56 PM
|
|
|
|
|
|
|
|
|