使用Visual Basic在xml文件中读取和写入自闭标签 [英] Reading and Writing self closing tags in an xml file using Visual Basic

查看:84
本文介绍了使用Visual Basic在xml文件中读取和写入自闭标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个难题,我甚至无法在网上找到任何内容,所以我希望有人可以帮助我。

I have a conundrum and I cannot find anything writtenon the web even close to it, so I am hoping that some one can kindly help me out.

我正在开发使用Visual Basic在Visual Studio 2015中的项目。  在我的项目中,我有一个部分,我将元素集附加到XML文件。 然后,我想将文件重新加载到我的项目中,或者将记录按字母顺序排序。 
我有一个Private Sub,它获取集合的元素,然后将它们附加到文件中。 问题是元素是用自闭项标记写的,因此< Row /> 而不是标准的标签格式,因为这个< Row> ..< / Row> 
我已经发现自闭项标签对于空元素是可以的,但似乎对于包含数据的元素不是这种情况。 当我添加了我的数据时,它具有自闭标记,然后如果我想将新数据集排序为
alpha order,则"Start Debugging"返回错误说

I am developing a project in Visual Studio 2015 using Visual Basic.   In my project I have a section where I append an element set to an XML file.  I then want to reload the file into my project or sort the records into alphabetical order.  I have a Private Sub which gets the elements of the set then appends them to the file.  The problem is that the elements are written with a self closing tag as this <Row />  and not the standard tag format as this <Row>..</Row>  I have figured out that the self closing tags are OK for an empty element but it seems that this is not the case for elements which contain data.  When I have appended my data it has the self closing tag, then if I want to sort the new set of data into alpha order the "Start Debugging" returns an error saying

CurrentYearSupplierInvoicePost.exe中出现未处理的"System.NullReferenceException"类型异常
An unhandled exception of type 'System.NullReferenceException' occurred in CurrentYearSupplierInvoicePost.exe

推荐答案

嗨Paul,

欢迎来到MSDN论坛。

Welcome to the MSDN forum.

请参阅您的描述,这个问题是关于VB.NET开发的。由于我们的论坛是讨论VS IDE,我将帮助您将此主题移至相应的论坛以寻求更好的支持,感谢您的理解。

Refer to your description, this issue is about VB.NET development. Since our forum is to discuss the VS IDE, I will help you move this thread to the appropriate forum to seek for a better support, thank you for your understanding.

致以最诚挚的问候,

Sara


这篇关于使用Visual Basic在xml文件中读取和写入自闭标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆