如何使用c#从此xml字符串中提取文本

时间:2018-01-03 18:15:30

标签: c# asp.net xml

我有一个方法,它返回从第三方库返回的Xml字符串文本。

我正在尝试获取3431的值,即Node AnalysisID

3431

我尝试使用/ DlmInput / Clustername / AnalysisId /

进行访问

无法解析。 你能帮我提一下这个价值吗?

由于 丽塔

<?xml version="1.0" encoding="utf-16"?>
<DlmInput
    xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://Hydra.EngineContracts">
    <ClusterName i:nil="true"
        xmlns="http://Hydra.EngineContracts.Data" />
        <IsRetry
            xmlns="http://Hydra.EngineContracts.Data">false
        </IsRetry>
        <JobId
            xmlns="http://Hydra.EngineContracts.Data">0
        </JobId>
        <JobType
            xmlns="http://Hydra.EngineContracts.Data">1
        </JobType>
        <MachineName
            xmlns="http://Hydra.EngineContracts.Data">06DV
        </MachineName>
        <MustSucceedAllTasks
            xmlns="http://Hydra.EngineContracts.Data">true
        </MustSucceedAllTasks>
        <Name
            xmlns="http://Hydra.EngineContracts.Data">Analysis for SubId: 216 ExpID: 4124 DlmProfileId: 1280
        </Name>
        <OutputString i:nil="true"
            xmlns="http://Hydra.EngineContracts.Data" />
            <ParentRequestId
                xmlns="http://Hydra.EngineContracts.Data">0
            </ParentRequestId>
            <ProgressMsg
                xmlns="http://Hydra.EngineContracts.Data">
            </ProgressMsg>
            <RoutingIdentifier i:nil="true"
                xmlns="http://Hydra.EngineContracts.Data" />
                <Status
                    xmlns="http://Hydra.EngineContracts.Data">Waiting
                </Status>
                <SubmitTime
                    xmlns="http://Hydra.EngineContracts.Data">2018-01-03T11:00:23.1700526-05:00
                </SubmitTime>
                <TaskExecutionContextId
                    xmlns="http://Hydra.EngineContracts.Data">0
                </TaskExecutionContextId>
                <TaskId
                    xmlns="http://Hydra.EngineContracts.Data">0
                </TaskId>
                <Tasks
                    xmlns="http://Hydra.EngineContracts.Data" />
                    <UserFields
                        xmlns="http://Hydra.EngineContracts.Data">
                    </UserFields>
                    <UserId
                        xmlns="http://Hydra.EngineContracts.Data">Service-XL-D
                    </UserId>
                    <AnalysisDescription>45 NA Winterstorm</AnalysisDescription>
                    <AnalysisId>3431</AnalysisId>
                    <AnalysisMode>2</AnalysisMode>
                    <AnalysisName>Analysis for SubId: 216 ExpID: 4124 DlmProfileId: 1280</AnalysisName>
                    <AnalysisType>102</AnalysisType>
                    <Currency>USD</Currency>
                    <EventTypeFilter>0</EventTypeFilter>
                    <ExposureDataModelConnectionString>DSN=EDM;UID=sa;PWD=;SERVER=7DV;DATABASE=EDM;Trusted_Connection=Yes;</ExposureDataModelConnectionString>
                    <Lob></Lob>
                    <ProfileConnectionString>DSN=DLM PROFILES;UID=sa;PWD=;SERVER=7DV;DATABASE=DLMPROFIL;Trusted_Connection=Yes;</ProfileConnectionString>
                    <Region></Region>
                    <ResultsDataModelConnectionString>DSN=RDM;UID=sa;PWD=;SERVER=7DV;DATABASE=Rdm;Trusted_Connection=Yes;</ResultsDataModelConnectionString>
                    <SrcEdm>RMS_EDM_G3P</SrcEdm>
                    <SrcEdmDbGuid>e9efb9e3-b5ef-415c-a7ec-74d0f816b8b7</SrcEdmDbGuid>
                    <SrcEdmSvrName>7DV</SrcEdmSvrName>
                    <TreatyIds
                        xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" />
                        <User1></User1>
                        <User2></User2>
                        <User3></User3>
                        <User4></User4>
                        <WorkflowStatus></WorkflowStatus>
                        <AnalysisHazardConnectionString>DSN=ANALYSISHAZARD;UID=sa;PWD=;SERVER=7DV;DATABASE=ANALYSISHAZARD;Trusted_Connection=Yes;</AnalysisHazardConnectionString>
                        <DlmConfig>[OUTPUTS]
ConfigDataSource=RMS EVENT INFO
DistanceLimit=800
</DlmConfig>
                        <EmploymentConnectionString>DSN=RMS EMPLOYMENT;UID=sa;PWD=;SERVER=7DV;DATABASE=RMS_EMPLOYMENT;Trusted_Connection=Yes;</EmploymentConnectionString>
                        <EngineType>100</EngineType>
                        <EventInfoConnectionString>DSN=RMS EVENT INFO;UID=sa;PWD=;SERVER=7DV;DATABASE=RMS_EVENTINFO_original;Trusted_Connection=Yes;</EventInfoConnectionString>
                        <ExposureId>4124</ExposureId>
                        <ExposureName>BrinksP100M</ExposureName>
                        <ExposureType>8019</ExposureType>
                        <GeoHazardConnectionString>DSN=RMS GEOHAZARD;UID=sa;PWD=;SERVER=7DV;DATABASE=RMS_GEOHAZARD;Trusted_Connection=Yes;</GeoHazardConnectionString>
                        <GeocodeConnectionString>DSN=RMS GEOCODE;UID=sa;PWD=;SERVER=7DV;DATABASE=RMS_GEOCODE;Trusted_Connection=Yes;</GeocodeConnectionString>
                        <GeographyConnectionString>DSN=RMS GEOGRAPHY;UID=sa;PWD=;SERVER=7DV;DATABASE=RMS_GEOGRAPHY;Trusted_Connection=Yes;</GeographyConnectionString>
                        <GroundMotionConnectionString>DSN=RMS GROUNDMOTION;UID=sa;PWD=;SERVER=7DV;DATABASE=RMS_GROUNDMOTION;Trusted_Connection=Yes;</GroundMotionConnectionString>
                        <HistoricalConnectionString>DSN=RMS HISTORICAL;UID=sa;PWD=;SERVER=7DV;DATABASE=RMS_HISTORICAL;Trusted_Connection=Yes;</HistoricalConnectionString>
                        <PerilType>WT</PerilType>
                        <ProfileId>1280</ProfileId>
                        <SkipUnrecognizedConstructionAndOccupancy>true</SkipUnrecognizedConstructionAndOccupancy>
                        <StochasticConnectionString>DSN=RMS STOCHASTIC;UID=sa;PWD=;SERVER=7DV;DATABASE=RMS_STOCHASTIC;Trusted_Connection=Yes;</StochasticConnectionString>
                        <SystemDataConnectionString>DSN=RMS SYSTEM DATA;UID=sa;PWD=;SERVER=7DV;DATABASE=RMS_SYSTEMDATA;Trusted_Connection=Yes;</SystemDataConnectionString>
                        <TargetConnectionString>DSN=RMS TARGET;UID=sa;PWD=;SERVER=7DV;DATABASE=RMS_TARGET;Trusted_Connection=Yes;</TargetConnectionString>
                        <TotalLocations>7</TotalLocations>
                        <UseCustomVulnCurves>0</UseCustomVulnCurves>
                        <UserConfigConnectionString>DSN=RMS USER CONFIG;UID=sa;PWD=;SERVER=7DV;DATABASE=RMS_USERCONFIG;Trusted_Connection=Yes;</UserConfigConnectionString>
                        <VulnerabilityConnectionString>DSN=RMS VULNERABILITY;UID=sa;PWD=;SERVER=7DV;DATABASE=RMS_VULNERABILITY;Trusted_Connection=Yes;</VulnerabilityConnectionString>
                    </DlmInput>

1 个答案:

答案 0 :(得分:0)

如果正确格式化XML,您会发现AnalysisId没有嵌套在Clustername中。

尝试使用/ DMInput / AnalysisId