Hi,
Been spinning on this for whole weekend I can't seem to get what you I want. I have the following xml result from my query. As you notice one of the child elements has the tag identifier VJobs, how can I make it so it says 'task' instead?
<task id="2" name="Saw 1" color="#99ccff" expand="true" />
<task id="3" name="Saw 2" color="#99ccff" expand="true" />
<VJobs id="3" name="Layout#" color="#99ccff" >
<customproper ty taskproperty-id="tpc0" value="Unknown" />
<customproper ty taskproperty-id="tpc1" value="17.938 " />
<customproper ty taskproperty-id="tpc2" value="Unknown" />
<customproper ty taskproperty-id="tpc3" value="0" />
<customproper ty taskproperty-id="tpc4" value="Operator Unknown" />
</VJobs>
</task>
Here is the query, which details jobs to be done on different equipments
SELECT EquipmentID + 1 as id,
EquipmentDescr as [name],
'#99ccff' AS color,
'true' AS [expand],
(SELECT JobID + 2AS id,
'Layout#' AS [name],
'#99ccff' AS color,
(SELECT [taskproperty-id] AS [taskproperty-id],
[value] AS [value]
FROM dbo.JobDetails customproperty
WHERE customproperty. JobID = VJobs.JobID
FOR XML AUTO, TYPE)
FROM VJobs
WHERE VJobs.Equipment ID = task.EquipmentI D
FOR XML AUTO, TYPE)
FROM VEquipments task
ORDER BY EquipmentDescr
FOR XML AUTO, TYPE
2 1384 deepuv04 227
Recognized Expert New Member
Hi,
try as first take the xml output as string ( into @String) then do a replace function and then convert the string (@string) as xml. -
DECLARE @String VARCHAR(MAX)
-
SET @String = ''
-
SET @String = CONVERT(VARCHAR(MAX),SELECT EquipmentID + 1 as id,
-
EquipmentDescr as [name],
-
'#99ccff' AS color,
-
'true' AS [expand],
-
(SELECT JobID + 2AS id,
-
'Layout#' AS [name],
-
'#99ccff' AS color,
-
(SELECT [taskproperty-id] AS [taskproperty-id],
-
[value] AS [value]
-
FROM dbo.JobDetails customproperty
-
WHERE customproperty.JobID = VJobs.JobID
-
FOR XML AUTO, TYPE)
-
FROM VJobs
-
WHERE VJobs.EquipmentID = task.EquipmentID
-
FOR XML AUTO, TYPE)
-
FROM VEquipments task
-
ORDER BY EquipmentDescr
-
FOR XML AUTO, TYPE)
-
-
SET @String = Replace(@String,'VJobs ','task')
-
-
SELECT convert(xml,@String)
-
-
-
-
Thanks
deepuv04
Ok is there a grammy award for tech guys cause you deserve one. It works great!!! Thank you so much!
I am using this for a GanttProject display, users are gonna love it.
Youhaev answered another question of mine..that is concatenating xml. That is now possible then since can convert to varchar, concatenate then convert to XML
YEE HAAAA thanks a lot!!!
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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...
|
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,...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
| |
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();...
|
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...
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |