Remplacer "& amp; lt;" et "& amp; gt;" par "& lt;" et "& gt;" dans le serveur sql
Salut, je suis nouveau sur pour xml
J'ai une requête de ce
SELECT ProjectId,
ProjectCode,
ProjectName,
TechId,
-- LocationId,
( SELECT GeoId,PoliticalDivisionId ,GeographicLocationName,IsoCode,Longitude,Latitude,ParentLocationId,
t2.CreatedBy,t2.CreatedOn,t2.LastUpdatedBy,t2.LastUpdatedOn
FROM GeographicLocation t2
WHERE GeoId = t1.LocationId
FOR XML PATH('Location') ),
RtoId,
CreatedBy,
CreatedOn,
LastUpdatedBy,
LastUpdatedOn
FROM Project t1
where ProjectId=1
FOR XML PATH('ProjectInfo')
renvoyer du xml sous
<ProjectInfo>
<ProjectId>1</ProjectId>
<ProjectCode>US-W1-00001</ProjectCode>
<ProjectName>Rees</ProjectName>
<TechId>1</TechId>
<Location><GeoId>235</GeoId><PoliticalDivisionId>2</PoliticalDivisionId><GeographicLocationName>UNITED STATES</GeographicLocationName><IsoCode>US</IsoCode></Location>
<RtoId>3</RtoId>
<CreatedBy>1</CreatedBy>
<CreatedOn>2013-06-30T20:55:21.587</CreatedOn>
<LastUpdatedBy>1</LastUpdatedBy>
<LastUpdatedOn>2013-06-30T20:55:21.587</LastUpdatedOn>
prject balises sont indiqués dans le formulaire < et > . Mais à l'intérieur des balises de Localisation sont affichées comme “<” et “>” comment puis-je les remplacer par < et >
Mise à jour : il y a une petite erreur dans la question . intérieure xml n'était pas pour rtoid , c'était pour l'Emplacement
J'ai mis à jour la requête comme
SELECT ProjectId,
ProjectCode,
ProjectName,
TechId,
-- LocationId,
replace(replace( ( SELECT GeoId,PoliticalDivisionId ,GeographicLocationName,IsoCode,Longitude,Latitude,ParentLocationId,
t2.CreatedBy,t2.CreatedOn,t2.LastUpdatedBy,t2.LastUpdatedOn
FROM GeographicLocation t2
WHERE GeoId = t1.LocationId
FOR XML PATH('Location') ), '<', '<'), '>', '>'),
RtoId,
CreatedBy,
CreatedOn,
LastUpdatedBy,
LastUpdatedOn
FROM Project t1
where ProjectId=1
FOR XML PATH('ProjectInfo')
mais toujours la même
source d'informationauteur Kuntady Nithesh | 2013-07-06
Vous devez vous connecter pour publier un commentaire.
Je pense que la bonne façon est d'utiliser TYPE de Directive
La façon que j'ai trouvé est explicitement les remplacer:
format de données au format xml, utilisez la fonction cast(@xml xml).
S'il vous plaît essayer: