473,695 Members | 2,464 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Changing format of XML Doc (using WriteXML?)

I am trying to get an output/file like this (below) in an XML file
(MyXmlFile.xml) (which I will use for a slide show)

--

<gallery timer="3" order="sequenti al" fadetime="2" looping="yes" xpos="0"

ypos="0">

<image path="images2/Test1.jpg" />

<image path="images2/Test2.jpg" />

<image path="images2/Test3.jpg" />

<image path="images2/Test4.jpg" />

<image path="images2/Test5.jpg" />

<image path="images2/Test6.jpg" />

</gallery>

--

When I use this XML file (written by hand), I can get the Flash slide show
to work, provided that the jpgs are in the correct folder....

So, now I want to generate the slide choices automatically from SQL, so I
added a table called StoreSlideShow, and added a key column, a StoreID
column, and a column called ImagePath.

I filled in the data, and wrote the SPROC

CREATE PROCEDURE [dbo].[GetSlideShowsBy Store3]

@StoreID int

AS

SELECT dbo.Stores.Stor eID, dbo.StoreSlideS how.ImagePath

FROM dbo.Stores INNER JOIN

dbo.StoreSlideS how ON dbo.Stores.Stor eID = dbo.StoreSlideS how.StoreID GO

----------------------

When I use the WriteXML command, etc..., it creates the following xml

document: (MyXmlFile3.xml )

<NewDataSet>

<Table>

<StoreID>1</StoreID>

<ImagePath>imag es2/Test1.jpg</ImagePath>

</Table>

<Table>

<StoreID>1</StoreID>

<ImagePath>imag es2/Test2.jpg</ImagePath>

</Table>

<Table>

<StoreID>1</StoreID>

<ImagePath>imag es2/Test3.jpg</ImagePath>

</Table>

....etc...

<Table>

<StoreID>2</StoreID>

<ImagePath>imag es2/Test1.jpg</ImagePath>

</Table>

</NewDataSet>

The data is correct, BUT - my dilemma- how do I get this output to match the
output/format above?

**TIA,**
Nov 12 '05 #1
2 2505

Paolo,

Is there anything that you are selecting from the database that is part
of the <gallery> element? If so, you could very easily write a SQL
statement with the FOR XML AUTO clause and let SQL Server return XML in
the format you need to.

Unfortunately, in order for FOR XML AUTO to work you need at least one
attribute from the Stores table to work. Would your flash code break if
there was an extra attribute? If not you could write a statement like:

SELECT gallery.StoreID as id, '3' as timer, 'sequential' as order, '2'
as fadetime, 'yes' as looping, '0' as xpos, '0' as ypos, image.ImagePath
as 'path' FROM Stores gallery INNER JOIN StoreSlideShow image ON ... FOR
XML AUTO

And then execute the results via the ExecuteXmlReade r() method on the
SqlCommand.

Again, for this to work you have to select at least on item in the
result set from the Stores table, otherwise you can't get the <gallery>
element in the response. I hope that an extra element will not throw off
your flash code.

If you can't go with that, then you could process the results with an
XSLT. It would go something like that (off the top of my head without
being able to validate it right now):

<xs:template match='/'>
<gallery timer="3" order="sequenti al" fadetime="2" looping="yes"
xpos="0" ypos="0">
<xs:apply-templates />
</gallery>
</xs:template>

<xs:template match='table'>
<image>
<xs:attribute name='path'><xs :value-of
select='ImagePa th'/></xs:attribute>
</image>
</xs:template>
HTH,
Christoph Schittko
MVP XML
http://weblogs.asp.net/cschittko
-----Original Message-----
From: Paolo Pignatelli [mailto:Pa***@Do tNetStore.com]
Posted At: Friday, December 17, 2004 7:15 AM
Posted To: microsoft.publi c.dotnet.xml
Conversation: Changing format of XML Doc (using WriteXML?)
Subject: Changing format of XML Doc (using WriteXML?)

I am trying to get an output/file like this (below) in an XML file
(MyXmlFile.xml) (which I will use for a slide show)

--

<gallery timer="3" order="sequenti al" fadetime="2" looping="yes" xpos="0"
ypos="0">

<image path="images2/Test1.jpg" />

<image path="images2/Test2.jpg" />

<image path="images2/Test3.jpg" />

<image path="images2/Test4.jpg" />

<image path="images2/Test5.jpg" />

<image path="images2/Test6.jpg" />

</gallery>

--

When I use this XML file (written by hand), I can get the Flash slide show to work, provided that the jpgs are in the correct folder....

So, now I want to generate the slide choices automatically from SQL, so I added a table called StoreSlideShow, and added a key column, a StoreID
column, and a column called ImagePath.

I filled in the data, and wrote the SPROC

CREATE PROCEDURE [dbo].[GetSlideShowsBy Store3]

@StoreID int

AS

SELECT dbo.Stores.Stor eID, dbo.StoreSlideS how.ImagePath

FROM dbo.Stores INNER JOIN

dbo.StoreSlideS how ON dbo.Stores.Stor eID = dbo.StoreSlideS how.StoreID GO
----------------------

When I use the WriteXML command, etc..., it creates the following xml

document: (MyXmlFile3.xml )

<NewDataSet>

<Table>

<StoreID>1</StoreID>

<ImagePath>imag es2/Test1.jpg</ImagePath>

</Table>

<Table>

<StoreID>1</StoreID>

<ImagePath>imag es2/Test2.jpg</ImagePath>

</Table>

<Table>

<StoreID>1</StoreID>

<ImagePath>imag es2/Test3.jpg</ImagePath>

</Table>

...etc...

<Table>

<StoreID>2</StoreID>

<ImagePath>imag es2/Test1.jpg</ImagePath>

</Table>

</NewDataSet>

The data is correct, BUT - my dilemma- how do I get this output to match the
output/format above?

**TIA,**

Nov 12 '05 #2
THANK YOU.

Let me go and work on this, and I may (probably will,) ask more questions.

Paolo
"Christoph Schittko [MVP]" <IN**********@a ustin.rr.com> wrote in message
news:#o******** ******@TK2MSFTN GP09.phx.gbl...

Paolo,

Is there anything that you are selecting from the database that is part
of the <gallery> element? If so, you could very easily write a SQL
statement with the FOR XML AUTO clause and let SQL Server return XML in
the format you need to.

Unfortunately, in order for FOR XML AUTO to work you need at least one
attribute from the Stores table to work. Would your flash code break if
there was an extra attribute? If not you could write a statement like:

SELECT gallery.StoreID as id, '3' as timer, 'sequential' as order, '2'
as fadetime, 'yes' as looping, '0' as xpos, '0' as ypos, image.ImagePath
as 'path' FROM Stores gallery INNER JOIN StoreSlideShow image ON ... FOR
XML AUTO

And then execute the results via the ExecuteXmlReade r() method on the
SqlCommand.

Again, for this to work you have to select at least on item in the
result set from the Stores table, otherwise you can't get the <gallery>
element in the response. I hope that an extra element will not throw off
your flash code.

If you can't go with that, then you could process the results with an
XSLT. It would go something like that (off the top of my head without
being able to validate it right now):

<xs:template match='/'>
<gallery timer="3" order="sequenti al" fadetime="2" looping="yes"
xpos="0" ypos="0">
<xs:apply-templates />
</gallery>
</xs:template>

<xs:template match='table'>
<image>
<xs:attribute name='path'><xs :value-of
select='ImagePa th'/></xs:attribute>
</image>
</xs:template>
HTH,
Christoph Schittko
MVP XML
http://weblogs.asp.net/cschittko
-----Original Message-----
From: Paolo Pignatelli [mailto:Pa***@Do tNetStore.com]
Posted At: Friday, December 17, 2004 7:15 AM
Posted To: microsoft.publi c.dotnet.xml
Conversation: Changing format of XML Doc (using WriteXML?)
Subject: Changing format of XML Doc (using WriteXML?)

I am trying to get an output/file like this (below) in an XML file
(MyXmlFile.xml) (which I will use for a slide show)

--

<gallery timer="3" order="sequenti al" fadetime="2" looping="yes"

xpos="0"

ypos="0">

<image path="images2/Test1.jpg" />

<image path="images2/Test2.jpg" />

<image path="images2/Test3.jpg" />

<image path="images2/Test4.jpg" />

<image path="images2/Test5.jpg" />

<image path="images2/Test6.jpg" />

</gallery>

--

When I use this XML file (written by hand), I can get the Flash slide

show
to work, provided that the jpgs are in the correct folder....

So, now I want to generate the slide choices automatically from SQL,

so I
added a table called StoreSlideShow, and added a key column, a StoreID
column, and a column called ImagePath.

I filled in the data, and wrote the SPROC

CREATE PROCEDURE [dbo].[GetSlideShowsBy Store3]

@StoreID int

AS

SELECT dbo.Stores.Stor eID, dbo.StoreSlideS how.ImagePath

FROM dbo.Stores INNER JOIN

dbo.StoreSlideS how ON dbo.Stores.Stor eID = dbo.StoreSlideS how.StoreID

GO

----------------------

When I use the WriteXML command, etc..., it creates the following xml

document: (MyXmlFile3.xml )

<NewDataSet>

<Table>

<StoreID>1</StoreID>

<ImagePath>imag es2/Test1.jpg</ImagePath>

</Table>

<Table>

<StoreID>1</StoreID>

<ImagePath>imag es2/Test2.jpg</ImagePath>

</Table>

<Table>

<StoreID>1</StoreID>

<ImagePath>imag es2/Test3.jpg</ImagePath>

</Table>

...etc...

<Table>

<StoreID>2</StoreID>

<ImagePath>imag es2/Test1.jpg</ImagePath>

</Table>

</NewDataSet>

The data is correct, BUT - my dilemma- how do I get this output to

match
the
output/format above?

**TIA,**


Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
8855
by: Nick | last post by:
Well, the project I am working on has now come to a screeching halt! I have been developing a program that heavily utilizes ADO.NET record sets. To generate reports, I convert the recordset to XML, and then apply an XSLT to transform the XML into HTML. This works great (or did) until today. I just found out that the "number-format" command in XSLT can't handle scientific notation! So when I try to format these numbers I just get "NaN" on...
0
1109
by: Kermit | last post by:
I am re-writing a vb script that queries an SQL server and then uses the recordset to generate an xml file. The xml file has a row-set schema with row as the element and the columns as attributes: <z:row ID="1" CapConDerivedName="AV_TOUCH_SCREEN_SOUND_LEVEL_ENABLED" DataStructureType="bool" EnumType="None" Unit="none" SetValue="0" DSTID="2" /> I am using C# and dataSet.WriteXml(fileName, XmlWriteMode.WriteSchema); The problem I am...
1
1371
by: Jacky | last post by:
hello i have to know if the writeXML process is a blocking process. Other mean if i write doc.WriteXML(); int i = 0; Is i = 0 can be executed before doc.WriteXML() method ended???? All this when the data we have to save can need up to 2 3 seconds. I think it's not blocking according to what I see in my application.
2
1447
by: Guoqi Zheng | last post by:
Dear sir, I am trying to create to writeXml to create a xml file every day. The WriteXml method of dataset is very nice and easy to use, however, how can I add the following to my xml file? <?xml version="1.0" encoding="UTF-8"?> <productFeed version="0" timestamp="20040105:22:00:05">
8
1583
by: John | last post by:
Hi I need to be able to call a web service method, receive the dataset that web method returns and store it in an access table. My problem is that I don't know how to "receive" a complex type like a dataset and how to link it to the access table that it is supposed to go in. Could someone please give me a code example? Thanks
7
2965
by: Sakharam Phapale | last post by:
Hi All, How to preserve the old font properties while changing new one? I posted same question 2 months back, but I had very small time then. eg. "Shopping for" is a text in RichTextBox and already formatted as "Shopping" ---Bold "for" -----Regular Now I want to underline whole text by preserving old style i.e. Bold and
3
9028
by: INeedADip | last post by:
I have seen this problem posted all over, but have never ran across a solution.... I am serializing my dataset and they look like this: <NewDataSet> <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
8
10447
by: Marc Gravell | last post by:
I want to write a method that will accept a stream as a parameter, and which will write xml to the stream (based in reality on database results) using the XmlTextWriter class. However, this insists on closing my stream, and I can't convince it not to. A much-simplified example is below; basically, as soon as the writer is disposed (marked **** below) the base stream gets closed - which is a pain if I was still using it ;-p The base...
4
1986
by: Trapulo | last post by:
I've a webservice with a string parameter. I call this webservice passing a string that is 1129 chars length. On the webservice, the received string is 1146 length (I tested sizes with string.length property). String's contents seem be teh same, so I think there is some encoding difference (is this possibile?). The problem is that I sign this string, so signature validation fails :( What can be the problem?
0
8617
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
8553
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8971
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8822
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8815
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5827
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4332
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2994
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2251
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.