Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在c中本地将web服务的响应字符串保存到xml文件中#_C#_Xml_Web Services_Model View Controller - Fatal编程技术网

C# 如何在c中本地将web服务的响应字符串保存到xml文件中#

C# 如何在c中本地将web服务的响应字符串保存到xml文件中#,c#,xml,web-services,model-view-controller,C#,Xml,Web Services,Model View Controller,我正在调用一个扩展名为.ashx的web服务,并获取字符串作为响应。现在我正在尝试将其保存在xml文件中。项目正确执行,但未保存在xml文件中 public void savexmlFile() { string wbserviceUrl = "https://someurl.ashx"; WebClient clientOne = new WebClient(); string result = clie

我正在调用一个扩展名为.ashx的web服务,并获取字符串作为响应。现在我正在尝试将其保存在xml文件中。项目正确执行,但未保存在xml文件中

 public void savexmlFile()
        {
            string wbserviceUrl = "https://someurl.ashx";
            WebClient clientOne = new WebClient();
            string result = clientOne.DownloadString(wbserviceUrl);

            XmlDocument cruisexmlDocument = new XmlDocument();
            cruisexmlDocument.LoadXml(result);
            cruisexmlDocument.Save("D:/brian office projects/Cruise/Cruise/XmlFiles/Cruisedata/cruiseproduts.xml");
        }
我该怎么做呢

这是我们直接在浏览器中输入url的结果

<CruiseData CreationDate="2015-11-11T00:00:03.9702000+00:00">
<CruiseProduct>
<ID>3706</ID>
<Name>MS SUNRISE SERMIRAMIS COLLECTION</Name>
<Description>
<p>Our Selected Nile Cruise <b>MS Sunrise Semiramis</b> <b>Collection Nile Cruise</b> the world’s greatest open air museum, to Aswan. Be enchanted by the fascinating landscape and rich cultural heritage. On our cruiser you will surely experience one of your most memorable vacations.<br><br><b>The Nile is the world's longest river</b> and a luxury cruise on an elegant ship is the most relaxing way to discover the cultural landmarks and archaeological sites of Egypt. Retrace the routes followed by Egypt's pharaohs from Luxor and wonder at the views over Lake Nasser from Aswan's High Dam.<br><b><br>We offer a choice of luxury Nile cruises</b> with various itineraries along the Nile and across Lake Nasser, and are delighted to feature a small selection of the most intimate, elegant and sophisticated vessels. Normal cruise itineraries include embarkation at Luxor, a cruise to Aswan, then disembarkation in Luxor, although some cruises end in Aswan, or can be booked from Aswan. For cruises ending or starting in Aswan, we can easily book travel between Aswan and Luxor.<br><br><b>Nile cruise holidays are an exceptional</b> way to visit some of Egypt’s most famed and most captivating sights. The famed Valley of the Kings contains more than sixty tombs, chambers and halls: the most famous, Tutankhamen, contains a tomb with the mummy in situ, and the Valley of the Queens offers interesting insights into the Egyptian way of life as Queens and royal children were buried in separate valleys. One of the most magnificent monuments is the Temple of Queen Hatshepsut: dedicated to Egypt’s greatest female pharaoh. The Colossi of Memnon which is two huge stone sentinels overlooking the Nile, requires special mention, as does the Temple of Luxor, and the Temple of Karnack with its daily Sound and Light Show.<br><br><b>With Combo Holidays River Nile cruises</b> covering the routes between Luxor and Aswan; the cruise itineraries feature some fantastic stops along the way. At Edfu there’s a very well preserved temple dedicated to Horus - the second largest temple in Egypt. The Aswan High Dam built during the 1960’s to stem annual floods and provide hydroelectricity, boasts good views over Lake Nasser, and the two islands of the Nile offer contrasting attractions; Kitchener's Island boasts the exotic Botanical Gardens and Elephantine Island is home to the Temple of Khnum with its ram mummies on view at the museum.<br><br><b>MS Sunrise Semiramis</b> will take you on a cruise from Luxor, the world’s greatest open air museum, to Aswan. Be enchanted by the fascinating landscape and rich cultural heritage. On our cruiser you will surely experience one of your most memorable vacations.<br><br><b>64 Standard Cabins</b> are waiting to welcome you. All cabins offer an amazing view on the Nile. The finest facilities can be

3706
MS SUNRISE SERMIRAMIS系列
我们精选的尼罗河邮轮MS Sunrise Semiramis收藏尼罗河邮轮世界上最大的露天博物馆,到阿斯旺。被迷人的风景和丰富的文化遗产迷住了。乘坐我们的巡洋舰,您一定会体验到最难忘的假期。

尼罗河是世界上最长的河流,乘坐优雅的轮船进行豪华巡游是发现埃及文化地标和考古遗址最轻松的方式。从卢克索回溯埃及法老的路线,从阿斯旺的高坝欣赏纳赛尔湖的美景。

我们提供沿尼罗河和横跨纳赛尔湖的各种路线的豪华尼罗河游轮选择,并很高兴有一小部分最私密、优雅和复杂的船只。正常的邮轮行程包括在卢克索登船,到阿斯旺的邮轮,然后在卢克索下船,尽管有些邮轮以阿斯旺为终点,或者可以从阿斯旺预订。对于在阿斯旺结束或开始的游轮,我们可以轻松预订阿斯旺和卢克索之间的行程。

尼罗河游轮假日是游览埃及最著名和最迷人景点的一种特殊方式。著名的国王谷有60多座坟墓、墓室和大厅:最著名的图坦卡门(Tutankhamen)有一座木乃伊墓,皇后谷(Valley of The Queens)提供了对埃及生活方式的有趣见解,因为皇后和王室子女被埋葬在不同的山谷中。最宏伟的纪念碑之一是哈特谢普苏特女王神庙:献给埃及最伟大的女性法老。门农巨像是两座俯瞰尼罗河的巨石哨兵,需要特别提及,卢克索神庙和卡纳克神庙每天都有声光表演。

随着Combo Holidays,尼罗河游轮覆盖了卢克索和阿斯旺之间的路线;邮轮路线沿途有一些精彩的停靠站。在埃德夫,有一座保存完好的神庙供奉着荷鲁斯——埃及第二大神庙。阿斯旺大坝建于20世纪60年代,用于阻挡每年的洪水并提供水电,拥有纳赛尔湖的美景,尼罗河的两个岛屿具有截然不同的吸引力;基奇纳岛以拥有异国情调的植物园而自豪,而Elephantine岛则是Khnum神庙的所在地,博物馆内陈列着公羊木乃伊。

Sunrise Semiramis女士将带您从世界上最大的露天博物馆卢克索乘船前往阿斯旺。被迷人的风景和丰富的文化遗产迷住了。在我们的巡洋舰上,您一定会体验到最难忘的假期之一。

64个标准舱正等着欢迎您。所有的小屋都能看到尼罗河上令人惊叹的景色。最好的设施可以是
字符串,从服务下载的u是否具有xml格式?如果不是,则返回cruisexmlDocument.LoadXml(结果);不会生效,它只是将XML字符串加载到内存中。

字符串,从服务下载的u是否具有XML格式?如果不是,则返回cruisexmlDocument.LoadXml(结果);不会生效,它只是加载到内存中的XML字符串。

只需下载内容,将其读取为字符串,然后写入即可。除非您需要以某种方式验证它是否是有效的XML,否则不需要将其作为XML处理。除此之外,只需下载并编写即可。确保您有写入路径的权限

        var httpClient = new HttpClient();
        var result = httpClient.GetAsync("your url").Result;
        System.IO.File.WriteAllText(@"C:\yourxml.xml", result.Content.ReadAsStringAsync().Result);

只要下载你的内容,把它读成字符串,然后写下来。除非您需要以某种方式验证它是否是有效的XML,否则不需要将其作为XML处理。除此之外,只需下载并编写即可。确保您有写入路径的权限

        var httpClient = new HttpClient();
        var result = httpClient.GetAsync("your url").Result;
        System.IO.File.WriteAllText(@"C:\yourxml.xml", result.Content.ReadAsStringAsync().Result);

1) 检查以确保路径正确,并且您具有对目录(以及预先存在的文件,如果存在)的写入权限。2)您确定XML字符串实际上包含任何内容吗?是的,我确定。因为我可以将字符串放入datatable。我这样做的原因是web服务需要花很多时间来加载(响应)1)检查以确保路径正确,并且您对目录(以及预先存在的文件,如果存在)具有写入权限。2)您确定XML字符串实际上包含任何内容吗?是的,我确定。因为我可以将字符串放入datatable。我之所以这样做是因为web服务需要花费大量时间来加载(响应)