XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming
Receive the tools necessary to be the rock star of your field. Our 12-month program teaches you the evolving world of multi-channel marketing as well as the complex issues and opportunities found in the industry.

ASP Free and Iron Speed Designer are giving away $5,500+ in FREE licenses. Iron Speed's RAD CASE toolset can save up to 80% of your coding time. One free license per week, one perpetual license per month!
Download and Activate to enter!

Web development can be a daunting task, even for specialists. There is a lot of information to absorb and a lot of technologies to learn in order to manage a superior website. When trying to learn the ropes, developers need a reliable source to introduce new ideas that can be easily implemented. When working on large projects, even web veterans may run into a technology or an aspect of a technology that they are unfamiliar with.

Learn More!


Download to Enter
| Contest Rules

Tutorials | Forums

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 27th, 2012, 06:27 AM
WilderBog WilderBog is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2012
Posts: 4 WilderBog User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 57 m 46 sec
Reputation Power: 0
XML Output

Hi,

I have posted this in the SQL forum however plenty of views and no replies so I am hoping someone here may be able to shed some light.

I have been trying to tailor a query which will return XML data back ready for use with the 'fusion charts'.

I have so far been 90% successful but a certain additional piece of info needs to be added for this to completely work.

the goal is for the result to appear as follows:

<chart caption='Calls Closed Today'
xAxisName='Specialist' yAxisName='Closed'>
<Set label="JOEB" Value="1" />
<Set label="JANEB" Value="2" />
<Set label="JACKB" Value="1" />
<Set label="JILLB" Value="2" />
<Set label="JOHNB" Value="5" />
<Set label="JULIEB" Value="5" />
<Set label="JAMESB" Value="5" />
</chart>

Now, by running the following query:

SELECT SpecialistID AS label, COUNT(1) AS Value FROM dbo.Request
WHERE ResolutionActual >= (DATEADD(D, 0, DATEDIFF(D, 0, GETDATE())))
AND SpecialistID IN ('JOEB', 'JANEB', 'JACKB', 'JILLB', 'JOHNB', 'JULIEB', 'JAMESB')
GROUP BY SpecialistID
FOR XML RAW ('set'), ROOT ('chart');

This produces the following result:

<chart>
<Set label="JOEB" Value="1" />
<Set label="JANEB" Value="2" />
<Set label="JACKB" Value="1" />
<Set label="JILLB" Value="2" />
<Set label="JOHNB" Value="5" />
<Set label="JULIEB" Value="5" />
<Set label="JAMESB" Value="5" />
</chart>

The item I am missing (as you will see) is the additional code stored within the <chart> element.

How am I able to work this code in? I have briefly looked at EXPLICIT XML output which is more controllable but there is little out there which would assist me with this particular instance.

I would appreciate any help given,
Thanks!

Reply With Quote
  #2  
Old January 27th, 2012, 05:32 PM
E-Oreo's Avatar
E-Oreo E-Oreo is offline
Moderator
Click here for more information.
 
Join Date: Dec 2004
Posts: 6,462 E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)  Folding Points: 945 Folding Title: Novice Folder
Time spent in forums: 1 Month 2 Weeks 4 Days 3 h 27 m 48 sec
Reputation Power: 6144
Quote:
FOR XML RAW ('set'), ROOT ('chart');

I'm pretty sure this is not "standard" SQL. What database server / version are you using?
__________________
How to program a basic, secure login system using PHP

Quote:
Originally Posted by Spad
Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

Reply With Quote
  #3  
Old January 28th, 2012, 09:58 AM
WilderBog WilderBog is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2012
Posts: 4 WilderBog User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 57 m 46 sec
Reputation Power: 0
Actually that is a perfectly acceptable RAW XML output,

FOR XML RAW ('set'), < here I am re-labelling the rows to display as 'set'.

ROOT ('chart');

the default for 'root' is to appear as <root> xml_code </root>

I have simply specified this to appear as 'chart'.

My guess is that RAW output may not be the way forward for me, it may be that EXPLICIT or PATH might need to be used but that involves re-writing everything and there is suprisingly small ammount of information about on this subject.

EDIT: to answer your question - MS SQL server 2008

Reply With Quote
  #4  
Old January 28th, 2012, 01:04 PM
E-Oreo's Avatar
E-Oreo E-Oreo is offline
Moderator
Click here for more information.
 
Join Date: Dec 2004
Posts: 6,462 E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)  Folding Points: 945 Folding Title: Novice Folder
Time spent in forums: 1 Month 2 Weeks 4 Days 3 h 27 m 48 sec
Reputation Power: 6144
I was able to infer what it meant, but that doesn't mean it's standard SQL. Your previous thread was posted in the MySQL forum, and since MySQL doesn't have anything like "FOR XML" it's not surprising that you didn't get any replies there.

I've never used MSSQL before, but some googling revealed that you might be able to do it with a nested query:
http://www.sqlservercentral.com/For...05934-21-1.aspx
Quote:
select getDate() as '@timestamp',
( select name as '@name', xtype as 'data/@xtype'
from sysobjects
for xml path('object'),type
)
for xml path('root')

Quote:
<root timestamp="july 25 2009" xmlns:h="http://www.w3.org/TR/html4/">
<object name="sysrowsetcolumns">
<data xtype="S" />
</object>
</root>

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > XML Output


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.

© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 5 - Follow our Sitemap