Entwickler-Ecke

IO, XML und Registry - einen String in Xml Parsen


Soier - Fr 13.02.15 00:14
Titel: einen String in Xml Parsen
Hi

programmiere gerade ne Anwendung und nutze die Amazaon api für. Diese liefert mir die Artikelinformation als Xml welche in der api als string gespeichert werden. Dies klappt nun wollte ich das in xml convertieren um einfacher das Xml file durch zu gehen um mir die benötigten Informationen rauszuhollen und diese variablen zuzuwiessen um diese in eine datenbank zu speichern.

mein Code


C#-Quelltext
1:
2:
XmlDocument doc = new XmlDocument();
         doc.LoadXml(informationstring);



allerdings steht dann in doc nicht die XML.

Evtl brauch ich ja gar nicht den string um zuparsen in xml um mir meine informationen rauszu hollen evtl geht das auch so wenn das einer von euch weiss.

mein "XML":


XML-Daten
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
<?xml version="1.0"?>

-<ItemLookupResponse xmlns="http://webservices.amazon.com/AWSECommerceService/2011-08-01">


-<OperationRequest>

<RequestId>375b3594-54b0-480b-856a-835d52eee657</RequestId>


-<Arguments>

<Argument Value="ItemLookup" Name="Operation"/>

<Argument Value="AWSECommerceService" Name="Service"/>

<Argument Value="AKIAITTSOMTETTUIR4PA" Name="AssociateTag"/>

<Argument Value="2009-03-31" Name="Version"/>

<Argument Value="YFICJlJSpB/0GJNIjG7RtwWYda3T3eykIElCfOl2oaA=" Name="Signature"/>

<Argument Value="B00IEOEFFK" Name="ItemId"/>

<Argument Value="AKIAITTSOMTETTUIR4PA" Name="AWSAccessKeyId"/>

<Argument Value="2015-02-12T20:15:27Z" Name="Timestamp"/>

<Argument Value="Offers,Small" Name="ResponseGroup"/>

</Arguments>

<RequestProcessingTime>0.0170470000000000</RequestProcessingTime>

</OperationRequest>


-<Items>


-<Request>

<IsValid>True</IsValid>


-<ItemLookupRequest>

<IdType>ASIN</IdType>

<ItemId>B00IEOEFFK</ItemId>

<ResponseGroup>Offers</ResponseGroup>

<ResponseGroup>Small</ResponseGroup>

<VariationPage>All</VariationPage>

</ItemLookupRequest>

</Request>


-<Item>

<ASIN>B00IEOEFFK</ASIN>

<DetailPageURL>http://www.amazon.de/Logitech-Proteus-Core-Tunable-Gaming/dp/B00IEOEFFK%3FSubscriptionId%3DAKIAITTSOMTETTUIR4PA%26tag%3DAKIAITTSOMTETTUIR4PA%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3DB00IEOEFFK</DetailPageURL>


-<ItemLinks>


-<ItemLink>

<Description>Add To Wishlist</Description>

<URL>http://www.amazon.de/gp/registry/wishlist/add-item.html%3Fasin.0%3DB00IEOEFFK%26SubscriptionId%3DAKIAITTSOMTETTUIR4PA%26tag%3DAKIAITTSOMTETTUIR4PA%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12738%26creativeASIN%3DB00IEOEFFK</URL>

</ItemLink>


-<ItemLink>

<Description>Tell A Friend</Description>

<URL>http://www.amazon.de/gp/pdp/taf/B00IEOEFFK%3FSubscriptionId%3DAKIAITTSOMTETTUIR4PA%26tag%3DAKIAITTSOMTETTUIR4PA%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12738%26creativeASIN%3DB00IEOEFFK</URL>

</ItemLink>


-<ItemLink>

<Description>All Customer Reviews</Description>

<URL>http://www.amazon.de/review/product/B00IEOEFFK%3FSubscriptionId%3DAKIAITTSOMTETTUIR4PA%26tag%3DAKIAITTSOMTETTUIR4PA%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12738%26creativeASIN%3DB00IEOEFFK</URL>

</ItemLink>


-<ItemLink>

<Description>All Offers</Description>

<URL>http://www.amazon.de/gp/offer-listing/B00IEOEFFK%3FSubscriptionId%3DAKIAITTSOMTETTUIR4PA%26tag%3DAKIAITTSOMTETTUIR4PA%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12738%26creativeASIN%3DB00IEOEFFK</URL>

</ItemLink>

</ItemLinks>


-<ItemAttributes>

<Manufacturer>Logitech</Manufacturer>

<ProductGroup>Computer & Zubehör</ProductGroup>

<Title>Logitech Proteus Core G502 Tunable Gaming Maus</Title>

</ItemAttributes>


-<OfferSummary>


-<LowestNewPrice>

<Amount>6600</Amount>

<CurrencyCode>EUR</CurrencyCode>

<FormattedPrice>EUR 66,00</FormattedPrice>

</LowestNewPrice>


-<LowestUsedPrice>

<Amount>5187</Amount>

<CurrencyCode>EUR</CurrencyCode>

<FormattedPrice>EUR 51,87</FormattedPrice>

</LowestUsedPrice>

<TotalNew>32</TotalNew>

<TotalUsed>16</TotalUsed>

<TotalCollectible>0</TotalCollectible>

<TotalRefurbished>0</TotalRefurbished>

</OfferSummary>


-<Offers>

<TotalOffers>1</TotalOffers>

<TotalOfferPages>1</TotalOfferPages>

<MoreOffersUrl>http://www.amazon.de/gp/offer-listing/B00IEOEFFK%3FSubscriptionId%3DAKIAITTSOMTETTUIR4PA%26tag%3DAKIAITTSOMTETTUIR4PA%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12738%26creativeASIN%3DB00IEOEFFK</MoreOffersUrl>


-<Offer>


-<OfferAttributes>

<Condition>New</Condition>

</OfferAttributes>


-<OfferListing>

<OfferListingId>dAQ4H%2F70HXOCxkwwoW5MEameedI7F85yGPegwWjE%2BXm%2FlBRUH66ESYeT%2FK1JDnsnjb%2BQTbtUkrWH7pBFxqSD2O2LOGk5pLjjLUMCxF3dO3U%3D</OfferListingId>


-<Price>

<Amount>6600</Amount>

<CurrencyCode>EUR</CurrencyCode>

<FormattedPrice>EUR 66,00</FormattedPrice>

</Price>

<Availability>Gewöhnlich versandfertig in 24 Stunden</Availability>


-<AvailabilityAttributes>

<AvailabilityType>now</AvailabilityType>

<MinimumHours>0</MinimumHours>

<MaximumHours>0</MaximumHours>

</AvailabilityAttributes>

<IsEligibleForSuperSaverShipping>1</IsEligibleForSuperSaverShipping>

</OfferListing>

</Offer>

</Offers>

</Item>

</Items>

</ItemLookupResponse>


danke für die Hilfe im vorraus

mfg

Soier


Ralf Jansen - Fr 13.02.15 00:32

Warum machst du das selber?

Die API scheint ein stinknormaler SOAP Webservice zu sein. Also solltest du einfach die WSDL in Visual Studio importieren könne und dir das komplette clientseitige Klassenkonstrukt generieren lassen. Du bekommst dann deine Produktdaten in entsprechenden Klassen. Sehe keinen Grund sich selbst mit dem XML rumzuschlagen.


Soier - Fr 13.02.15 21:32

ja weil das nicht ging irgendwie :/

so hab ichs hin bekomme hab aber gerade wie gesagt das problem das die xml in nem string steht und ich die parsen möchte kann aber den string nicht in ein richtiges xml umwandeln ;/