Ich habe eine SQL Server-Datenbank mit 3 Tabellen und ich muss eine XML-Datei mit hierarchischer Struktur aus diesen Tabellen erstellen.Erstellen Sie hierarchische XML aus SQL Server-Tabellen
Eine Tabelle enthält Produkte:
ProductID ProductLanguageID ProductDefaultShopID ProductNumber ProductName ProductPrice
------------------------------------------------------------------------------------------
[email protected]@Inc LANG2 Inc 100101 ABC 159,61
[email protected]@Inc LANG2 Inc 100102 BCD 159,61
[email protected]@Inc LANG2 Inc 100105 FRE 159,61
[email protected]@Inc LANG2 Inc 100106 GDE 159,61
die zweite hat Gruppen
GroupID GroupLanguageID GroupName GroupNumber
------------------------------------------------------------
[email protected]@Inc LANG2 AAA 1
[email protected]@Inc LANG2 BBB 1.01
[email protected]@Inc LANG2 CCC 1.02
[email protected]@Inc LANG2 DDD 1.03
[email protected]@Inc LANG2 GGG 1.12
die dritte Sprachen
LanguageID LanguageCode2 LanguageName
----------------------------------------
LANG1 ES Spain
LANG2 EN English
Ich habe auch 2 Tabellen, die keine Verbindungen haben dont zu weitere Tabellen:
TabelleGruppe Relations
GroupRelationsGroupID GroupRelationsParentID
--------------------------------------------
[email protected]@Inc [email protected]@Inc
[email protected]@Inc [email protected]@Inc
[email protected]@Inc [email protected]@Inc
[email protected]@Inc [email protected]@Inc
Group Product Relation Tabelle
GroupProductRelationGroupID GroupProductRelationProductID
-------------------------------------------------------------
[email protected]@Inc [email protected]@Inc
[email protected]@Inc [email protected]@Inc
[email protected]@Inc [email protected]@Inc
Die XML-Ausgabe folgende Struktur haben sollte:
<?xml version="1.0" encoding="utf-8"?>
<root>
<productgroup1>
<groupname>AAA</groupname>
<productgroup2>
<groupname>BBB</groupname>
<productgroup3>
<groupname>CCC</groupname>
<products>
<product>
<itemName>ABC</itemName>
<itemNumber>100303</itemNumber>
<itemPrice>159.61</itemPrice>
<ExtraProductgroup>
<extraProductgroupName>GGG</extraProductgroupName>
<itemName>FRE</itemName>
<itemNumber>100305</itemNumber>
<itemPrice>159.61</itemPrice>
</ExtraProductgroup>
</product>
<product>
<itemName>BCD</itemName>
<itemNumber>100302</itemNumber>
<itemPrice>159.61</itemPrice>
</product>
</products>
</productgroup3>
</productgroup2>
</productgroup1>
</root>
Ich kann nur verwenden T-SQL und C# (ASP. Netz Web Forms). HILFE!!! :-)
Ich sehe keine Möglichkeit, dass XML aus diesen Daten zu erhalten. Woher kommt beispielsweise itemColor? Was ist mit ExtraProduktgruppe? Wenn Sie möchten, dass jemand eine Chance hat, erstellen Sie mindestens die gewünschte Ausgabe von der gegebenen Eingabe von Hand. Ansonsten raten wir nur hier. –
Sie haben eine ProductNumber und eine ProductID ist die Nummer mit '@@ Inc' - Was ist die * real * ID? Scheint seltsam ... Keiner von ihnen ist irgendwo in den anderen Daten zu finden. Wie ist ein Produkt an eine Gruppe gebunden? Die Gruppen scheinen hierarchisch geschachtelt zu sein. Gibt es eine maximale Tiefe? Gruppen- und Gruppenbeziehung halten IDs, die nicht in der Gruppentabelle gefunden werden können ... Sie müssen ** funktionierende Beispieldaten mit einer Beispielausgabe bereitstellen, die zu diesen Daten passt !! ** Bereiten Sie eine [MCVE] vor (http: // stackoverflow. com/help/mcve) (Code oder [Geige] (www.sqlfiddle.com) – Shnugo