XML模式中的@符号 [英] @ Symbol within XML Schema

查看:114
本文介绍了XML模式中的@符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

新年快乐,

新年快乐,任何帮助将不胜感激.

我有一个称为Web服务的Winform项目.传递XML字符串.

当我将XML传递到Web服务时,它可以正常工作,并且可以毫无问题地插入到数据集中,但是,只要在XML中包含电子邮件地址,数据集就可以


Dim strXML As String =< parameters>< parameterline>"细节< machineid" Pal0066</machineid>< printer> Printer1</printer> ; username> TomUser</username>"
strXML& ="< reportname> CanteenBilling</reportname>< receiptmethod>电子邮件</receiptmethod>< format> PDF<> ; =< emailto> email@problemishere.co.uk</emailto>< emailcc>//emailcc>< emailbcc></emailbcc>< emailsubject></emailsubject>" & =< emailbody>/emailbody</details> reportparameters> location< 1>/location</reportparameters>//parameterline</parameters>"


骗局vertXMLIntoDS(StrXML)


私有函数ConvertXMLIntoDS(ByVal strXML As String)作为Data.DataSet
        
           将Dim ds用作新Data.DataSet
        昏暗的阅读器,如System.IO.StringReader
        尝试
                  reader =新的System.IO.StringReader(strXML)
               ds.ReadXml(阅读器)
                 ConvertXMLIntoDS = ds

          异常捕获
                  " RunReports.AddLog("ConvertXMLIntoDS-错误")
                  ''RunReports.AddError(例如,methodBase.Name)
        最后
                 如果不是,则

                     ds.Dispose()
                        ds = Nothing
                 如果结束
                 如果不是Isnothing(阅读器),那么
                        reader.Dispose()
                      读者=没什么
              如果结束
           结束尝试

        
     结束函数

解决方案

诱人写道:

数据集无法正确创建的XML ?



创建不正确"是什么意思?

以下C#产生了预期的电子邮件地址.

string sxml = "<root><mail>hello@mymail.com</mail></root>";<br />DataSet ds = new DataSet();<br />ds.ReadXml(new System.IO.StringReader(sxml));<br />Console.WriteLine(ds.Tables[0].Rows[0].ItemArray[0].ToString());<br /><br />




Happy New Year,

Strange one to start the year off, any help would be appreciated.

I have a Winform Project calling a web service.   passing in an XML string.

When I pass through my XML to the webservice, it works fine and gets inserted into the dataset without a problem, however as soon as I include an email address within the XML the dataset does not create correctly?


Dim strXML As String = "<parameters><parameterline><details><machineid>Pal0066</machineid><printer>Printer1</printer><username>TomUser</username>"
strXML &= "<reportname>CanteenBilling</reportname><receiptmethod>Email</receiptmethod><format>PDF</format>"
strXML &= "<emailto>email@problemishere.co.uk</emailto><emailcc></emailcc><emailbcc></emailbcc><emailsubject></emailsubject>"
strXML &= "<emailbody></emailbody></details><reportparameters><location>1</location></reportparameters></parameterline></parameters>"


ConvertXMLIntoDS(StrXML)


Private Function ConvertXMLIntoDS(ByVal strXML As String) As Data.DataSet
           
            Dim ds As New Data.DataSet
            Dim reader As System.IO.StringReader
            Try
                  reader = New System.IO.StringReader(strXML)
                  ds.ReadXml(reader)
                  ConvertXMLIntoDS = ds

            Catch ex As Exception
                  ''RunReports.AddLog("ConvertXMLIntoDS - Error")
                  ''RunReports.AddError(ex, methodBase.Name)
            Finally
                  If Not IsNothing(ds) Then
                        ds.Dispose()
                        ds = Nothing
                  End If
                  If Not IsNothing(reader) Then
                        reader.Dispose()
                        reader = Nothing
                  End If
            End Try

        
      End Function

解决方案

tomkettering wrote:

the XML the dataset does not create correctly?



"does not create correctly" means what?

The following C# produces the email address as expected.

string sxml = "<root><mail>hello@mymail.com</mail></root>";<br />DataSet ds = new DataSet();<br />ds.ReadXml(new System.IO.StringReader(sxml));<br />Console.WriteLine(ds.Tables[0].Rows[0].ItemArray[0].ToString());<br /><br />




这篇关于XML模式中的@符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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