我有一个 SQL Server 数据库,我需要使用从 api 调用返回的 xml 填充它。这是返回的 xml 代码(不在文件中):
<petfinder xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://api.petfinder.com/schemas/0.9/petfinder.xsd">
<header>
<version>0.1</version>
<timestamp>2013-04-08T14:52:23Z</timestamp>
<status>
<code>100</code>
<message/>
</status>
</header>
<lastOffset>25</lastOffset>
<pets>
<pet>
<id>18589607</id>
<shelterId>OK98</shelterId>
<shelterPetId>11C-0015</shelterPetId>
<name>Sam</name>
<animal>Cat</animal>
<breeds>
<breed>Domestic Short Hair</breed>
<breed>Tabby</breed>
</breeds>
<mix>yes</mix>
<age>Adult</age>
<sex>M</sex>
<size>XL</size>
<options>
<option>altered</option>
<option>hasShots</option>
<option>housebroken</option>
</options>
<description>
<![CDATA[
<div>This guy loves the camera. Look at him pose and show off! Sam is about 5 years old and is a cream Tabby. He is good with other cats and is house trained. He has turquoise eyes and is a sweet sweet cat. Sam loves to be the right hand man and assist you on any task you may have. Sammy is not the type of cat that likes to be held but will sit right next to you for some rubbing and head butting. Our adoption fee is $100 for dogs and $75 for cats. This adoption fee includes the spay or neutering and rabies shot. </div>
]]>
</description>
<lastUpdate>2012-07-24T14:50:17Z</lastUpdate>
<status>A</status>
<media>
<photos>
<photo id="1" size="x">
http://photos.petfinder.com/photos/US/OK/OK98/18589607/OK98.18589607-1-x.jpg
</photo>
<photo id="1" size="fpm">
http://photos.petfinder.com/photos/US/OK/OK98/18589607/OK98.18589607-1-fpm.jpg
</photo>
<photo id="1" size="pn">
http://photos.petfinder.com/photos/US/OK/OK98/18589607/OK98.18589607-1-pn.jpg
</photo>
<photo id="1" size="pnt">
http://photos.petfinder.com/photos/US/OK/OK98/18589607/OK98.18589607-1-pnt.jpg
</photo>
<photo id="1" size="t">
http://photos.petfinder.com/photos/US/OK/OK98/18589607/OK98.18589607-1-t.jpg
</photo>
<photo id="2" size="x">
http://photos.petfinder.com/photos/US/OK/OK98/18589607/OK98.18589607-2-x.jpg
</photo>
<photo id="2" size="fpm">
http://photos.petfinder.com/photos/US/OK/OK98/18589607/OK98.18589607-2-fpm.jpg
</photo>
<photo id="2" size="pn">
http://photos.petfinder.com/photos/US/OK/OK98/18589607/OK98.18589607-2-pn.jpg
</photo>
<photo id="2" size="pnt">
http://photos.petfinder.com/photos/US/OK/OK98/18589607/OK98.18589607-2-pnt.jpg
</photo>
<photo id="2" size="t">
http://photos.petfinder.com/photos/US/OK/OK98/18589607/OK98.18589607-2-t.jpg
</photo>
<photo id="3" size="x">
http://photos.petfinder.com/photos/US/OK/OK98/18589607/OK98.18589607-3-x.jpg
</photo>
<photo id="3" size="fpm">
http://photos.petfinder.com/photos/US/OK/OK98/18589607/OK98.18589607-3-fpm.jpg
</photo>
<photo id="3" size="pn">
http://photos.petfinder.com/photos/US/OK/OK98/18589607/OK98.18589607-3-pn.jpg
</photo>
<photo id="3" size="pnt">
http://photos.petfinder.com/photos/US/OK/OK98/18589607/OK98.18589607-3-pnt.jpg
</photo>
<photo id="3" size="t">
http://photos.petfinder.com/photos/US/OK/OK98/18589607/OK98.18589607-3-t.jpg
</photo>
</photos>
</media>
<contact>
<address1>714 Martin Luther King Jr Ave</address1>
<address2/>
<city>Duncan</city>
<state>OK</state>
<zip>73533</zip>
<phone/>
<fax/>
<email/>
</contact>
</pet>
...
更具体地说,我需要获取 ID、名称、动物、描述和其他几个节点,并将它们插入到我数据库中相应的列中。
它必须对所有这些都在其中的每个“宠物”节点重复此操作。
我可以在 VB.net 中执行此操作而不保存文件,就像 xml 字符串一样吗?
请帮忙,我已经坚持了好几天了。