doc.LoadXml在根级别提供错误数据无效

时间:2014-11-25 10:50:38

标签: c# xml

我正在使用xml响应,如下所示

       <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <CreateMeetMeOrWebMeetingResults 
xmlns:ns2="coss-ws-common">
<transactionId>z8kflt5fi2x28vd51</transactionId>
<status>OK</status>
<meetme id="178635601">
    <billingCode>MR5942965</billingCode>
    <confirmationId>Q-1GFR347H6I</confirmationId>
    <serviceId>1021</serviceId>
    <serviceName>BT MeetMe</serviceName>
    <timezone>America/New_York</timezone>
    <topic>Danny Chung</topic>
    <chairpasscode>34132738</chairpasscode>
    <participantpasscode>84781442</participantpasscode>
    <dialInNumber>
        <phoneType>PSTN</phoneType>
        <formattedNumber>0203 463 9676</formattedNumber>
        <displayName>Direct: 0203 463 9676</displayName>
        <rawNumber>02034639676</rawNumber>
    </dialInNumber>
    <createDate>2014-11-25T09:34:33.168Z</createDate>
    <createdByApplicationId>1120</createdByApplicationId>
    <bridgeId>892</bridgeId>
    <recurringFlag>false</recurringFlag>
    <globalAccessFeature locked="false" enabled="true">
        <url>Please contact help desk</url>
    </globalAccessFeature>
    <meetingType>MEETME</meetingType>
    <serviceType>MEETME</serviceType>
    <pendingBlackoutDateApproval>false</pendingBlackoutDateApproval>
    <chairpersonRecord locked="false" enabled="true"/>
</meetme>
 </CreateMeetMeOrWebMeetingResults>

我试图通过doc.LoadXml(响应)将其转换为xml,并在根级别为无效数据提供错误。 如果有人可以帮助解决问题

2 个答案:

答案 0 :(得分:1)

如果这是您的完整 xml,则错过了结束标记

</CreateMeetMeOrWebMeetingResults>

尝试在xml底部添加

查看缩进,可能是您的xml以空格开头。这可能是另一个原因

答案 1 :(得分:-1)

您似乎没有xml的根元素。这对我有用。

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<root>
    <CreateMeetMeOrWebMeetingResults xmlns:ns2="coss-ws-common"/>
    <transactionId>z8kflt5fi2x28vd51</transactionId>
    <status>OK</status>
    <meetme id="178635601">
        <billingCode>MR5942965</billingCode>
        <confirmationId>Q-1GFR347H6I</confirmationId>
        <serviceId>1021</serviceId>
        <serviceName>BT MeetMe</serviceName>
        <timezone>America/New_York</timezone>
        <topic>Danny Chung</topic>
        <chairpasscode>34132738</chairpasscode>
        <participantpasscode>84781442</participantpasscode>
        <dialInNumber>
            <phoneType>PSTN</phoneType>
            <formattedNumber>0203 463 9676</formattedNumber>
            <displayName>Direct: 0203 463 9676</displayName>
            <rawNumber>02034639676</rawNumber>
        </dialInNumber>
        <createDate>2014-11-25T09:34:33.168Z</createDate>
        <createdByApplicationId>1120</createdByApplicationId>
        <bridgeId>892</bridgeId>
        <recurringFlag>false</recurringFlag>
        <globalAccessFeature locked="false" enabled="true">
            <url>Please contact help desk</url>
        </globalAccessFeature>
        <meetingType>MEETME</meetingType>
        <serviceType>MEETME</serviceType>
        <pendingBlackoutDateApproval>false</pendingBlackoutDateApproval>
        <chairpersonRecord locked="false" enabled="true"/>
    </meetme>
</root>