Can't get path to XML element in SOAP
I have an XML file for VB.NET to read. My code is specific to the file.
How can I read the value of the <Value> associated with the <Key> LNGYIL?

My code:
Dim doc As XDocument
doc = XDocument.Load("c:jpanfaturalar.xml")
Dim lngyil= (
From v In doc.<soap>.<soap>.<IntegrationGetEntitySetWithPacketLoginResponse>.<IntegrationGetEntitySetWithPacketLoginResult>.<ResultEntitySet>.<CustomData>.<ArrayOfClsDictionaryOfStringObject>.<clsDictionaryOfStringObject>
Where v.<Key>.Value = "LNGYIL"
Select v.<Value>.Value
).Single()
ListBox1.Items.Insert(0, lngyil)
XML source:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><IntegrationGetEntitySetWithPacketLoginResponse xmlns="http://integration.univera.com.tr"><IntegrationGetEntitySetWithPacketLoginResult><ResultString>OK</ResultString><IsSuccess>true</IsSuccess><ResultEntitySet><GorevSonucBilgiler/><DistUnvan/><PaketAdi/><Warnings/><PaketTanimlar><clsPaketTanim><Kod xsi:nil="true"/><Tabloadi>CUSTOMVIEW_ENTVIEWFATURAGENERIC_OZGUN</Tabloadi><Viewadi>CUSTOMVIEW_ENTVIEWFATURAGENERIC_OZGUN</Viewadi><Yon xsi:nil="true"/><Kriter>"(LNGDISTKOD = 12) AND BYTTUR IN(0,1) AND (LNGYIL = 2018) AND (BYTDURUM = 0)"</Kriter><Durum xsi:nil="true"/></clsPaketTanim></PaketTanimlar><SatirBazliTransaction>false</SatirBazliTransaction><LogKategori>0</LogKategori><IntegrationGorevSonucTip>0</IntegrationGorevSonucTip><errorLoglist/><SCCall>false</SCCall><ReturnLoglist>false</ReturnLoglist><StokSil>false</StokSil><CustomData><ArrayOfClsDictionaryOfStringObject><clsDictionaryOfStringObject><Key>LNGYIL</Key><Value xsi:type="xsd:int">2018</Value></clsDictionaryOfStringObject><clsDictionaryOfStringObject><Key>LNGDISTKOD</Key><Value xsi:type="xsd:int">12</Value></clsDictionaryOfStringObject><clsDictionaryOfStringObject><Key>TXTDISTKOD</Key><Value xsi:type="xsd:string">SH012</Value></clsDictionaryOfStringObject><clsDictionaryOfStringObject><Key>TXTSTKOD</Key><Value xsi:type="xsd:string">SH010</Value></clsDictionaryOfStringObject></ArrayOfClsDictionaryOfStringObject></CustomData></ResultEntitySet></IntegrationGetEntitySetWithPacketLoginResult></IntegrationGetEntitySetWithPacketLoginResponse></soap:Body></soap:Envelope>
Currently I get nothing.
xml vb.net soap xsd
add a comment |
I have an XML file for VB.NET to read. My code is specific to the file.
How can I read the value of the <Value> associated with the <Key> LNGYIL?

My code:
Dim doc As XDocument
doc = XDocument.Load("c:jpanfaturalar.xml")
Dim lngyil= (
From v In doc.<soap>.<soap>.<IntegrationGetEntitySetWithPacketLoginResponse>.<IntegrationGetEntitySetWithPacketLoginResult>.<ResultEntitySet>.<CustomData>.<ArrayOfClsDictionaryOfStringObject>.<clsDictionaryOfStringObject>
Where v.<Key>.Value = "LNGYIL"
Select v.<Value>.Value
).Single()
ListBox1.Items.Insert(0, lngyil)
XML source:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><IntegrationGetEntitySetWithPacketLoginResponse xmlns="http://integration.univera.com.tr"><IntegrationGetEntitySetWithPacketLoginResult><ResultString>OK</ResultString><IsSuccess>true</IsSuccess><ResultEntitySet><GorevSonucBilgiler/><DistUnvan/><PaketAdi/><Warnings/><PaketTanimlar><clsPaketTanim><Kod xsi:nil="true"/><Tabloadi>CUSTOMVIEW_ENTVIEWFATURAGENERIC_OZGUN</Tabloadi><Viewadi>CUSTOMVIEW_ENTVIEWFATURAGENERIC_OZGUN</Viewadi><Yon xsi:nil="true"/><Kriter>"(LNGDISTKOD = 12) AND BYTTUR IN(0,1) AND (LNGYIL = 2018) AND (BYTDURUM = 0)"</Kriter><Durum xsi:nil="true"/></clsPaketTanim></PaketTanimlar><SatirBazliTransaction>false</SatirBazliTransaction><LogKategori>0</LogKategori><IntegrationGorevSonucTip>0</IntegrationGorevSonucTip><errorLoglist/><SCCall>false</SCCall><ReturnLoglist>false</ReturnLoglist><StokSil>false</StokSil><CustomData><ArrayOfClsDictionaryOfStringObject><clsDictionaryOfStringObject><Key>LNGYIL</Key><Value xsi:type="xsd:int">2018</Value></clsDictionaryOfStringObject><clsDictionaryOfStringObject><Key>LNGDISTKOD</Key><Value xsi:type="xsd:int">12</Value></clsDictionaryOfStringObject><clsDictionaryOfStringObject><Key>TXTDISTKOD</Key><Value xsi:type="xsd:string">SH012</Value></clsDictionaryOfStringObject><clsDictionaryOfStringObject><Key>TXTSTKOD</Key><Value xsi:type="xsd:string">SH010</Value></clsDictionaryOfStringObject></ArrayOfClsDictionaryOfStringObject></CustomData></ResultEntitySet></IntegrationGetEntitySetWithPacketLoginResult></IntegrationGetEntitySetWithPacketLoginResponse></soap:Body></soap:Envelope>
Currently I get nothing.
xml vb.net soap xsd
stackoverflow.com/questions/15933333/how-to-read-an-xml-file Find a Solution Here
– Prakash
Nov 26 '18 at 7:29
Thanks but No standart data in node tag.
– Hasan Fehmi B.
Nov 26 '18 at 7:46
add a comment |
I have an XML file for VB.NET to read. My code is specific to the file.
How can I read the value of the <Value> associated with the <Key> LNGYIL?

My code:
Dim doc As XDocument
doc = XDocument.Load("c:jpanfaturalar.xml")
Dim lngyil= (
From v In doc.<soap>.<soap>.<IntegrationGetEntitySetWithPacketLoginResponse>.<IntegrationGetEntitySetWithPacketLoginResult>.<ResultEntitySet>.<CustomData>.<ArrayOfClsDictionaryOfStringObject>.<clsDictionaryOfStringObject>
Where v.<Key>.Value = "LNGYIL"
Select v.<Value>.Value
).Single()
ListBox1.Items.Insert(0, lngyil)
XML source:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><IntegrationGetEntitySetWithPacketLoginResponse xmlns="http://integration.univera.com.tr"><IntegrationGetEntitySetWithPacketLoginResult><ResultString>OK</ResultString><IsSuccess>true</IsSuccess><ResultEntitySet><GorevSonucBilgiler/><DistUnvan/><PaketAdi/><Warnings/><PaketTanimlar><clsPaketTanim><Kod xsi:nil="true"/><Tabloadi>CUSTOMVIEW_ENTVIEWFATURAGENERIC_OZGUN</Tabloadi><Viewadi>CUSTOMVIEW_ENTVIEWFATURAGENERIC_OZGUN</Viewadi><Yon xsi:nil="true"/><Kriter>"(LNGDISTKOD = 12) AND BYTTUR IN(0,1) AND (LNGYIL = 2018) AND (BYTDURUM = 0)"</Kriter><Durum xsi:nil="true"/></clsPaketTanim></PaketTanimlar><SatirBazliTransaction>false</SatirBazliTransaction><LogKategori>0</LogKategori><IntegrationGorevSonucTip>0</IntegrationGorevSonucTip><errorLoglist/><SCCall>false</SCCall><ReturnLoglist>false</ReturnLoglist><StokSil>false</StokSil><CustomData><ArrayOfClsDictionaryOfStringObject><clsDictionaryOfStringObject><Key>LNGYIL</Key><Value xsi:type="xsd:int">2018</Value></clsDictionaryOfStringObject><clsDictionaryOfStringObject><Key>LNGDISTKOD</Key><Value xsi:type="xsd:int">12</Value></clsDictionaryOfStringObject><clsDictionaryOfStringObject><Key>TXTDISTKOD</Key><Value xsi:type="xsd:string">SH012</Value></clsDictionaryOfStringObject><clsDictionaryOfStringObject><Key>TXTSTKOD</Key><Value xsi:type="xsd:string">SH010</Value></clsDictionaryOfStringObject></ArrayOfClsDictionaryOfStringObject></CustomData></ResultEntitySet></IntegrationGetEntitySetWithPacketLoginResult></IntegrationGetEntitySetWithPacketLoginResponse></soap:Body></soap:Envelope>
Currently I get nothing.
xml vb.net soap xsd
I have an XML file for VB.NET to read. My code is specific to the file.
How can I read the value of the <Value> associated with the <Key> LNGYIL?

My code:
Dim doc As XDocument
doc = XDocument.Load("c:jpanfaturalar.xml")
Dim lngyil= (
From v In doc.<soap>.<soap>.<IntegrationGetEntitySetWithPacketLoginResponse>.<IntegrationGetEntitySetWithPacketLoginResult>.<ResultEntitySet>.<CustomData>.<ArrayOfClsDictionaryOfStringObject>.<clsDictionaryOfStringObject>
Where v.<Key>.Value = "LNGYIL"
Select v.<Value>.Value
).Single()
ListBox1.Items.Insert(0, lngyil)
XML source:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><IntegrationGetEntitySetWithPacketLoginResponse xmlns="http://integration.univera.com.tr"><IntegrationGetEntitySetWithPacketLoginResult><ResultString>OK</ResultString><IsSuccess>true</IsSuccess><ResultEntitySet><GorevSonucBilgiler/><DistUnvan/><PaketAdi/><Warnings/><PaketTanimlar><clsPaketTanim><Kod xsi:nil="true"/><Tabloadi>CUSTOMVIEW_ENTVIEWFATURAGENERIC_OZGUN</Tabloadi><Viewadi>CUSTOMVIEW_ENTVIEWFATURAGENERIC_OZGUN</Viewadi><Yon xsi:nil="true"/><Kriter>"(LNGDISTKOD = 12) AND BYTTUR IN(0,1) AND (LNGYIL = 2018) AND (BYTDURUM = 0)"</Kriter><Durum xsi:nil="true"/></clsPaketTanim></PaketTanimlar><SatirBazliTransaction>false</SatirBazliTransaction><LogKategori>0</LogKategori><IntegrationGorevSonucTip>0</IntegrationGorevSonucTip><errorLoglist/><SCCall>false</SCCall><ReturnLoglist>false</ReturnLoglist><StokSil>false</StokSil><CustomData><ArrayOfClsDictionaryOfStringObject><clsDictionaryOfStringObject><Key>LNGYIL</Key><Value xsi:type="xsd:int">2018</Value></clsDictionaryOfStringObject><clsDictionaryOfStringObject><Key>LNGDISTKOD</Key><Value xsi:type="xsd:int">12</Value></clsDictionaryOfStringObject><clsDictionaryOfStringObject><Key>TXTDISTKOD</Key><Value xsi:type="xsd:string">SH012</Value></clsDictionaryOfStringObject><clsDictionaryOfStringObject><Key>TXTSTKOD</Key><Value xsi:type="xsd:string">SH010</Value></clsDictionaryOfStringObject></ArrayOfClsDictionaryOfStringObject></CustomData></ResultEntitySet></IntegrationGetEntitySetWithPacketLoginResult></IntegrationGetEntitySetWithPacketLoginResponse></soap:Body></soap:Envelope>
Currently I get nothing.
xml vb.net soap xsd
xml vb.net soap xsd
edited Nov 26 '18 at 19:50
Andrew Morton
15.5k53151
15.5k53151
asked Nov 26 '18 at 6:51
Hasan Fehmi B.Hasan Fehmi B.
696
696
stackoverflow.com/questions/15933333/how-to-read-an-xml-file Find a Solution Here
– Prakash
Nov 26 '18 at 7:29
Thanks but No standart data in node tag.
– Hasan Fehmi B.
Nov 26 '18 at 7:46
add a comment |
stackoverflow.com/questions/15933333/how-to-read-an-xml-file Find a Solution Here
– Prakash
Nov 26 '18 at 7:29
Thanks but No standart data in node tag.
– Hasan Fehmi B.
Nov 26 '18 at 7:46
stackoverflow.com/questions/15933333/how-to-read-an-xml-file Find a Solution Here
– Prakash
Nov 26 '18 at 7:29
stackoverflow.com/questions/15933333/how-to-read-an-xml-file Find a Solution Here
– Prakash
Nov 26 '18 at 7:29
Thanks but No standart data in node tag.
– Hasan Fehmi B.
Nov 26 '18 at 7:46
Thanks but No standart data in node tag.
– Hasan Fehmi B.
Nov 26 '18 at 7:46
add a comment |
1 Answer
1
active
oldest
votes
You need to code it to deal with the namespaces. One way is to use Imports statements like this:
Imports <xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
Imports <xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
Imports <xmlns:xsd="http://www.w3.org/2001/XMLSchema">
Imports <xmlns="http://integration.univera.com.tr">
Module Module1
Sub Main()
Dim x As XElement = <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<IntegrationGetEntitySetWithPacketLoginResponse xmlns="http://integration.univera.com.tr">
<IntegrationGetEntitySetWithPacketLoginResult>
<ResultString>OK</ResultString>
<IsSuccess>true</IsSuccess>
<ResultEntitySet>
<GorevSonucBilgiler/>
<DistUnvan/>
<PaketAdi/>
<Warnings/>
<PaketTanimlar>
<clsPaketTanim>
<Kod xsi:nil="true"/>
<Tabloadi>CUSTOMVIEW_ENTVIEWFATURAGENERIC_OZGUN</Tabloadi>
<Viewadi>CUSTOMVIEW_ENTVIEWFATURAGENERIC_OZGUN</Viewadi>
<Yon xsi:nil="true"/>
<Kriter>"(LNGDISTKOD = 12) AND BYTTUR IN(0,1) AND (LNGYIL = 2018) AND (BYTDURUM = 0)"</Kriter>
<Durum xsi:nil="true"/>
</clsPaketTanim>
</PaketTanimlar>
<SatirBazliTransaction>false</SatirBazliTransaction>
<LogKategori>0</LogKategori>
<IntegrationGorevSonucTip>0</IntegrationGorevSonucTip>
<errorLoglist/>
<SCCall>false</SCCall>
<ReturnLoglist>false</ReturnLoglist>
<StokSil>false</StokSil>
<CustomData>
<ArrayOfClsDictionaryOfStringObject>
<clsDictionaryOfStringObject>
<Key>LNGYIL</Key>
<Value xsi:type="xsd:int">2018</Value>
</clsDictionaryOfStringObject>
<clsDictionaryOfStringObject>
<Key>LNGDISTKOD</Key>
<Value xsi:type="xsd:int">12</Value>
</clsDictionaryOfStringObject>
<clsDictionaryOfStringObject>
<Key>TXTDISTKOD</Key>
<Value xsi:type="xsd:string">SH012</Value>
</clsDictionaryOfStringObject>
<clsDictionaryOfStringObject>
<Key>TXTSTKOD</Key>
<Value xsi:type="xsd:string">SH010</Value>
</clsDictionaryOfStringObject>
</ArrayOfClsDictionaryOfStringObject>
</CustomData>
</ResultEntitySet>
</IntegrationGetEntitySetWithPacketLoginResult>
</IntegrationGetEntitySetWithPacketLoginResponse>
</soap:Body>
</soap:Envelope>
Dim doc = New XDocument(x)
Dim q = doc.<soap:Envelope>.<soap:Body>.<IntegrationGetEntitySetWithPacketLoginResponse>.<IntegrationGetEntitySetWithPacketLoginResult>.<ResultEntitySet>.<CustomData>.<ArrayOfClsDictionaryOfStringObject>.<clsDictionaryOfStringObject>
Dim lngyil = (
From v In q
Where v.<Key>.Value = "LNGYIL"
Select v.<Value>.Value
).Single()
Console.WriteLine(lngyil)
Console.ReadLine()
End Sub
End Module
Outputs:
2018
P.S. I have a suspicion that xmlns="http://integration.univera.com.tr" is not valid, and it should be something like xmlns:univera="http://integration.univera.com.tr". That change makes the following possible...
A second option
Instead of using Imports statements, you can use an XmlNamespaceManager like this:
Imports System.Xml
Imports System.Xml.XPath
Module Module1
Sub Main()
Dim x As XElement = <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<IntegrationGetEntitySetWithPacketLoginResponse xmlns:univera="http://integration.univera.com.tr">
<IntegrationGetEntitySetWithPacketLoginResult>
<ResultString>OK</ResultString>
<IsSuccess>true</IsSuccess>
<ResultEntitySet>
<GorevSonucBilgiler/>
<DistUnvan/>
<PaketAdi/>
<Warnings/>
<PaketTanimlar>
<clsPaketTanim>
<Kod xsi:nil="true"/>
<Tabloadi>CUSTOMVIEW_ENTVIEWFATURAGENERIC_OZGUN</Tabloadi>
<Viewadi>CUSTOMVIEW_ENTVIEWFATURAGENERIC_OZGUN</Viewadi>
<Yon xsi:nil="true"/>
<Kriter>"(LNGDISTKOD = 12) AND BYTTUR IN(0,1) AND (LNGYIL = 2018) AND (BYTDURUM = 0)"</Kriter>
<Durum xsi:nil="true"/>
</clsPaketTanim>
</PaketTanimlar>
<SatirBazliTransaction>false</SatirBazliTransaction>
<LogKategori>0</LogKategori>
<IntegrationGorevSonucTip>0</IntegrationGorevSonucTip>
<errorLoglist/>
<SCCall>false</SCCall>
<ReturnLoglist>false</ReturnLoglist>
<StokSil>false</StokSil>
<CustomData>
<ArrayOfClsDictionaryOfStringObject>
<clsDictionaryOfStringObject>
<Key>LNGYIL</Key>
<Value xsi:type="xsd:int">2018</Value>
</clsDictionaryOfStringObject>
<clsDictionaryOfStringObject>
<Key>LNGDISTKOD</Key>
<Value xsi:type="xsd:int">12</Value>
</clsDictionaryOfStringObject>
<clsDictionaryOfStringObject>
<Key>TXTDISTKOD</Key>
<Value xsi:type="xsd:string">SH012</Value>
</clsDictionaryOfStringObject>
<clsDictionaryOfStringObject>
<Key>TXTSTKOD</Key>
<Value xsi:type="xsd:string">SH010</Value>
</clsDictionaryOfStringObject>
</ArrayOfClsDictionaryOfStringObject>
</CustomData>
</ResultEntitySet>
</IntegrationGetEntitySetWithPacketLoginResult>
</IntegrationGetEntitySetWithPacketLoginResponse>
</soap:Body>
</soap:Envelope>
Dim doc = New XDocument(x)
Dim nt As NameTable = New NameTable()
Dim nsmgr As XmlNamespaceManager = New XmlNamespaceManager(nt)
nsmgr.AddNamespace("soap", "http://schemas.xmlsoap.org/soap/envelope/")
nsmgr.AddNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance")
nsmgr.AddNamespace("xsd", "http://www.w3.org/2001/XMLSchema")
nsmgr.AddNamespace("univera", "http://integration.univera.com.tr")
Dim a = doc.XPathSelectElements("/soap:Envelope/soap:Body/IntegrationGetEntitySetWithPacketLoginResponse/IntegrationGetEntitySetWithPacketLoginResult/ResultEntitySet/CustomData/ArrayOfClsDictionaryOfStringObject/clsDictionaryOfStringObject", nsmgr)
Dim lngyil2 = (
From v In a
Where v.XPathSelectElement("Key").Value = "LNGYIL"
Select v.XPathSelectElement("Value").Value
).Single()
Console.WriteLine(lngyil2)
Console.ReadLine()
End Sub
End Module
More work on the XPath query would let you get the value directly without the loop after it.
Refs:
- Imports Statement (XML Namespace)
- Can't get value with XPath in Soap XML
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53475992%2fcant-get-path-to-xml-element-in-soap%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You need to code it to deal with the namespaces. One way is to use Imports statements like this:
Imports <xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
Imports <xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
Imports <xmlns:xsd="http://www.w3.org/2001/XMLSchema">
Imports <xmlns="http://integration.univera.com.tr">
Module Module1
Sub Main()
Dim x As XElement = <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<IntegrationGetEntitySetWithPacketLoginResponse xmlns="http://integration.univera.com.tr">
<IntegrationGetEntitySetWithPacketLoginResult>
<ResultString>OK</ResultString>
<IsSuccess>true</IsSuccess>
<ResultEntitySet>
<GorevSonucBilgiler/>
<DistUnvan/>
<PaketAdi/>
<Warnings/>
<PaketTanimlar>
<clsPaketTanim>
<Kod xsi:nil="true"/>
<Tabloadi>CUSTOMVIEW_ENTVIEWFATURAGENERIC_OZGUN</Tabloadi>
<Viewadi>CUSTOMVIEW_ENTVIEWFATURAGENERIC_OZGUN</Viewadi>
<Yon xsi:nil="true"/>
<Kriter>"(LNGDISTKOD = 12) AND BYTTUR IN(0,1) AND (LNGYIL = 2018) AND (BYTDURUM = 0)"</Kriter>
<Durum xsi:nil="true"/>
</clsPaketTanim>
</PaketTanimlar>
<SatirBazliTransaction>false</SatirBazliTransaction>
<LogKategori>0</LogKategori>
<IntegrationGorevSonucTip>0</IntegrationGorevSonucTip>
<errorLoglist/>
<SCCall>false</SCCall>
<ReturnLoglist>false</ReturnLoglist>
<StokSil>false</StokSil>
<CustomData>
<ArrayOfClsDictionaryOfStringObject>
<clsDictionaryOfStringObject>
<Key>LNGYIL</Key>
<Value xsi:type="xsd:int">2018</Value>
</clsDictionaryOfStringObject>
<clsDictionaryOfStringObject>
<Key>LNGDISTKOD</Key>
<Value xsi:type="xsd:int">12</Value>
</clsDictionaryOfStringObject>
<clsDictionaryOfStringObject>
<Key>TXTDISTKOD</Key>
<Value xsi:type="xsd:string">SH012</Value>
</clsDictionaryOfStringObject>
<clsDictionaryOfStringObject>
<Key>TXTSTKOD</Key>
<Value xsi:type="xsd:string">SH010</Value>
</clsDictionaryOfStringObject>
</ArrayOfClsDictionaryOfStringObject>
</CustomData>
</ResultEntitySet>
</IntegrationGetEntitySetWithPacketLoginResult>
</IntegrationGetEntitySetWithPacketLoginResponse>
</soap:Body>
</soap:Envelope>
Dim doc = New XDocument(x)
Dim q = doc.<soap:Envelope>.<soap:Body>.<IntegrationGetEntitySetWithPacketLoginResponse>.<IntegrationGetEntitySetWithPacketLoginResult>.<ResultEntitySet>.<CustomData>.<ArrayOfClsDictionaryOfStringObject>.<clsDictionaryOfStringObject>
Dim lngyil = (
From v In q
Where v.<Key>.Value = "LNGYIL"
Select v.<Value>.Value
).Single()
Console.WriteLine(lngyil)
Console.ReadLine()
End Sub
End Module
Outputs:
2018
P.S. I have a suspicion that xmlns="http://integration.univera.com.tr" is not valid, and it should be something like xmlns:univera="http://integration.univera.com.tr". That change makes the following possible...
A second option
Instead of using Imports statements, you can use an XmlNamespaceManager like this:
Imports System.Xml
Imports System.Xml.XPath
Module Module1
Sub Main()
Dim x As XElement = <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<IntegrationGetEntitySetWithPacketLoginResponse xmlns:univera="http://integration.univera.com.tr">
<IntegrationGetEntitySetWithPacketLoginResult>
<ResultString>OK</ResultString>
<IsSuccess>true</IsSuccess>
<ResultEntitySet>
<GorevSonucBilgiler/>
<DistUnvan/>
<PaketAdi/>
<Warnings/>
<PaketTanimlar>
<clsPaketTanim>
<Kod xsi:nil="true"/>
<Tabloadi>CUSTOMVIEW_ENTVIEWFATURAGENERIC_OZGUN</Tabloadi>
<Viewadi>CUSTOMVIEW_ENTVIEWFATURAGENERIC_OZGUN</Viewadi>
<Yon xsi:nil="true"/>
<Kriter>"(LNGDISTKOD = 12) AND BYTTUR IN(0,1) AND (LNGYIL = 2018) AND (BYTDURUM = 0)"</Kriter>
<Durum xsi:nil="true"/>
</clsPaketTanim>
</PaketTanimlar>
<SatirBazliTransaction>false</SatirBazliTransaction>
<LogKategori>0</LogKategori>
<IntegrationGorevSonucTip>0</IntegrationGorevSonucTip>
<errorLoglist/>
<SCCall>false</SCCall>
<ReturnLoglist>false</ReturnLoglist>
<StokSil>false</StokSil>
<CustomData>
<ArrayOfClsDictionaryOfStringObject>
<clsDictionaryOfStringObject>
<Key>LNGYIL</Key>
<Value xsi:type="xsd:int">2018</Value>
</clsDictionaryOfStringObject>
<clsDictionaryOfStringObject>
<Key>LNGDISTKOD</Key>
<Value xsi:type="xsd:int">12</Value>
</clsDictionaryOfStringObject>
<clsDictionaryOfStringObject>
<Key>TXTDISTKOD</Key>
<Value xsi:type="xsd:string">SH012</Value>
</clsDictionaryOfStringObject>
<clsDictionaryOfStringObject>
<Key>TXTSTKOD</Key>
<Value xsi:type="xsd:string">SH010</Value>
</clsDictionaryOfStringObject>
</ArrayOfClsDictionaryOfStringObject>
</CustomData>
</ResultEntitySet>
</IntegrationGetEntitySetWithPacketLoginResult>
</IntegrationGetEntitySetWithPacketLoginResponse>
</soap:Body>
</soap:Envelope>
Dim doc = New XDocument(x)
Dim nt As NameTable = New NameTable()
Dim nsmgr As XmlNamespaceManager = New XmlNamespaceManager(nt)
nsmgr.AddNamespace("soap", "http://schemas.xmlsoap.org/soap/envelope/")
nsmgr.AddNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance")
nsmgr.AddNamespace("xsd", "http://www.w3.org/2001/XMLSchema")
nsmgr.AddNamespace("univera", "http://integration.univera.com.tr")
Dim a = doc.XPathSelectElements("/soap:Envelope/soap:Body/IntegrationGetEntitySetWithPacketLoginResponse/IntegrationGetEntitySetWithPacketLoginResult/ResultEntitySet/CustomData/ArrayOfClsDictionaryOfStringObject/clsDictionaryOfStringObject", nsmgr)
Dim lngyil2 = (
From v In a
Where v.XPathSelectElement("Key").Value = "LNGYIL"
Select v.XPathSelectElement("Value").Value
).Single()
Console.WriteLine(lngyil2)
Console.ReadLine()
End Sub
End Module
More work on the XPath query would let you get the value directly without the loop after it.
Refs:
- Imports Statement (XML Namespace)
- Can't get value with XPath in Soap XML
add a comment |
You need to code it to deal with the namespaces. One way is to use Imports statements like this:
Imports <xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
Imports <xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
Imports <xmlns:xsd="http://www.w3.org/2001/XMLSchema">
Imports <xmlns="http://integration.univera.com.tr">
Module Module1
Sub Main()
Dim x As XElement = <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<IntegrationGetEntitySetWithPacketLoginResponse xmlns="http://integration.univera.com.tr">
<IntegrationGetEntitySetWithPacketLoginResult>
<ResultString>OK</ResultString>
<IsSuccess>true</IsSuccess>
<ResultEntitySet>
<GorevSonucBilgiler/>
<DistUnvan/>
<PaketAdi/>
<Warnings/>
<PaketTanimlar>
<clsPaketTanim>
<Kod xsi:nil="true"/>
<Tabloadi>CUSTOMVIEW_ENTVIEWFATURAGENERIC_OZGUN</Tabloadi>
<Viewadi>CUSTOMVIEW_ENTVIEWFATURAGENERIC_OZGUN</Viewadi>
<Yon xsi:nil="true"/>
<Kriter>"(LNGDISTKOD = 12) AND BYTTUR IN(0,1) AND (LNGYIL = 2018) AND (BYTDURUM = 0)"</Kriter>
<Durum xsi:nil="true"/>
</clsPaketTanim>
</PaketTanimlar>
<SatirBazliTransaction>false</SatirBazliTransaction>
<LogKategori>0</LogKategori>
<IntegrationGorevSonucTip>0</IntegrationGorevSonucTip>
<errorLoglist/>
<SCCall>false</SCCall>
<ReturnLoglist>false</ReturnLoglist>
<StokSil>false</StokSil>
<CustomData>
<ArrayOfClsDictionaryOfStringObject>
<clsDictionaryOfStringObject>
<Key>LNGYIL</Key>
<Value xsi:type="xsd:int">2018</Value>
</clsDictionaryOfStringObject>
<clsDictionaryOfStringObject>
<Key>LNGDISTKOD</Key>
<Value xsi:type="xsd:int">12</Value>
</clsDictionaryOfStringObject>
<clsDictionaryOfStringObject>
<Key>TXTDISTKOD</Key>
<Value xsi:type="xsd:string">SH012</Value>
</clsDictionaryOfStringObject>
<clsDictionaryOfStringObject>
<Key>TXTSTKOD</Key>
<Value xsi:type="xsd:string">SH010</Value>
</clsDictionaryOfStringObject>
</ArrayOfClsDictionaryOfStringObject>
</CustomData>
</ResultEntitySet>
</IntegrationGetEntitySetWithPacketLoginResult>
</IntegrationGetEntitySetWithPacketLoginResponse>
</soap:Body>
</soap:Envelope>
Dim doc = New XDocument(x)
Dim q = doc.<soap:Envelope>.<soap:Body>.<IntegrationGetEntitySetWithPacketLoginResponse>.<IntegrationGetEntitySetWithPacketLoginResult>.<ResultEntitySet>.<CustomData>.<ArrayOfClsDictionaryOfStringObject>.<clsDictionaryOfStringObject>
Dim lngyil = (
From v In q
Where v.<Key>.Value = "LNGYIL"
Select v.<Value>.Value
).Single()
Console.WriteLine(lngyil)
Console.ReadLine()
End Sub
End Module
Outputs:
2018
P.S. I have a suspicion that xmlns="http://integration.univera.com.tr" is not valid, and it should be something like xmlns:univera="http://integration.univera.com.tr". That change makes the following possible...
A second option
Instead of using Imports statements, you can use an XmlNamespaceManager like this:
Imports System.Xml
Imports System.Xml.XPath
Module Module1
Sub Main()
Dim x As XElement = <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<IntegrationGetEntitySetWithPacketLoginResponse xmlns:univera="http://integration.univera.com.tr">
<IntegrationGetEntitySetWithPacketLoginResult>
<ResultString>OK</ResultString>
<IsSuccess>true</IsSuccess>
<ResultEntitySet>
<GorevSonucBilgiler/>
<DistUnvan/>
<PaketAdi/>
<Warnings/>
<PaketTanimlar>
<clsPaketTanim>
<Kod xsi:nil="true"/>
<Tabloadi>CUSTOMVIEW_ENTVIEWFATURAGENERIC_OZGUN</Tabloadi>
<Viewadi>CUSTOMVIEW_ENTVIEWFATURAGENERIC_OZGUN</Viewadi>
<Yon xsi:nil="true"/>
<Kriter>"(LNGDISTKOD = 12) AND BYTTUR IN(0,1) AND (LNGYIL = 2018) AND (BYTDURUM = 0)"</Kriter>
<Durum xsi:nil="true"/>
</clsPaketTanim>
</PaketTanimlar>
<SatirBazliTransaction>false</SatirBazliTransaction>
<LogKategori>0</LogKategori>
<IntegrationGorevSonucTip>0</IntegrationGorevSonucTip>
<errorLoglist/>
<SCCall>false</SCCall>
<ReturnLoglist>false</ReturnLoglist>
<StokSil>false</StokSil>
<CustomData>
<ArrayOfClsDictionaryOfStringObject>
<clsDictionaryOfStringObject>
<Key>LNGYIL</Key>
<Value xsi:type="xsd:int">2018</Value>
</clsDictionaryOfStringObject>
<clsDictionaryOfStringObject>
<Key>LNGDISTKOD</Key>
<Value xsi:type="xsd:int">12</Value>
</clsDictionaryOfStringObject>
<clsDictionaryOfStringObject>
<Key>TXTDISTKOD</Key>
<Value xsi:type="xsd:string">SH012</Value>
</clsDictionaryOfStringObject>
<clsDictionaryOfStringObject>
<Key>TXTSTKOD</Key>
<Value xsi:type="xsd:string">SH010</Value>
</clsDictionaryOfStringObject>
</ArrayOfClsDictionaryOfStringObject>
</CustomData>
</ResultEntitySet>
</IntegrationGetEntitySetWithPacketLoginResult>
</IntegrationGetEntitySetWithPacketLoginResponse>
</soap:Body>
</soap:Envelope>
Dim doc = New XDocument(x)
Dim nt As NameTable = New NameTable()
Dim nsmgr As XmlNamespaceManager = New XmlNamespaceManager(nt)
nsmgr.AddNamespace("soap", "http://schemas.xmlsoap.org/soap/envelope/")
nsmgr.AddNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance")
nsmgr.AddNamespace("xsd", "http://www.w3.org/2001/XMLSchema")
nsmgr.AddNamespace("univera", "http://integration.univera.com.tr")
Dim a = doc.XPathSelectElements("/soap:Envelope/soap:Body/IntegrationGetEntitySetWithPacketLoginResponse/IntegrationGetEntitySetWithPacketLoginResult/ResultEntitySet/CustomData/ArrayOfClsDictionaryOfStringObject/clsDictionaryOfStringObject", nsmgr)
Dim lngyil2 = (
From v In a
Where v.XPathSelectElement("Key").Value = "LNGYIL"
Select v.XPathSelectElement("Value").Value
).Single()
Console.WriteLine(lngyil2)
Console.ReadLine()
End Sub
End Module
More work on the XPath query would let you get the value directly without the loop after it.
Refs:
- Imports Statement (XML Namespace)
- Can't get value with XPath in Soap XML
add a comment |
You need to code it to deal with the namespaces. One way is to use Imports statements like this:
Imports <xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
Imports <xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
Imports <xmlns:xsd="http://www.w3.org/2001/XMLSchema">
Imports <xmlns="http://integration.univera.com.tr">
Module Module1
Sub Main()
Dim x As XElement = <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<IntegrationGetEntitySetWithPacketLoginResponse xmlns="http://integration.univera.com.tr">
<IntegrationGetEntitySetWithPacketLoginResult>
<ResultString>OK</ResultString>
<IsSuccess>true</IsSuccess>
<ResultEntitySet>
<GorevSonucBilgiler/>
<DistUnvan/>
<PaketAdi/>
<Warnings/>
<PaketTanimlar>
<clsPaketTanim>
<Kod xsi:nil="true"/>
<Tabloadi>CUSTOMVIEW_ENTVIEWFATURAGENERIC_OZGUN</Tabloadi>
<Viewadi>CUSTOMVIEW_ENTVIEWFATURAGENERIC_OZGUN</Viewadi>
<Yon xsi:nil="true"/>
<Kriter>"(LNGDISTKOD = 12) AND BYTTUR IN(0,1) AND (LNGYIL = 2018) AND (BYTDURUM = 0)"</Kriter>
<Durum xsi:nil="true"/>
</clsPaketTanim>
</PaketTanimlar>
<SatirBazliTransaction>false</SatirBazliTransaction>
<LogKategori>0</LogKategori>
<IntegrationGorevSonucTip>0</IntegrationGorevSonucTip>
<errorLoglist/>
<SCCall>false</SCCall>
<ReturnLoglist>false</ReturnLoglist>
<StokSil>false</StokSil>
<CustomData>
<ArrayOfClsDictionaryOfStringObject>
<clsDictionaryOfStringObject>
<Key>LNGYIL</Key>
<Value xsi:type="xsd:int">2018</Value>
</clsDictionaryOfStringObject>
<clsDictionaryOfStringObject>
<Key>LNGDISTKOD</Key>
<Value xsi:type="xsd:int">12</Value>
</clsDictionaryOfStringObject>
<clsDictionaryOfStringObject>
<Key>TXTDISTKOD</Key>
<Value xsi:type="xsd:string">SH012</Value>
</clsDictionaryOfStringObject>
<clsDictionaryOfStringObject>
<Key>TXTSTKOD</Key>
<Value xsi:type="xsd:string">SH010</Value>
</clsDictionaryOfStringObject>
</ArrayOfClsDictionaryOfStringObject>
</CustomData>
</ResultEntitySet>
</IntegrationGetEntitySetWithPacketLoginResult>
</IntegrationGetEntitySetWithPacketLoginResponse>
</soap:Body>
</soap:Envelope>
Dim doc = New XDocument(x)
Dim q = doc.<soap:Envelope>.<soap:Body>.<IntegrationGetEntitySetWithPacketLoginResponse>.<IntegrationGetEntitySetWithPacketLoginResult>.<ResultEntitySet>.<CustomData>.<ArrayOfClsDictionaryOfStringObject>.<clsDictionaryOfStringObject>
Dim lngyil = (
From v In q
Where v.<Key>.Value = "LNGYIL"
Select v.<Value>.Value
).Single()
Console.WriteLine(lngyil)
Console.ReadLine()
End Sub
End Module
Outputs:
2018
P.S. I have a suspicion that xmlns="http://integration.univera.com.tr" is not valid, and it should be something like xmlns:univera="http://integration.univera.com.tr". That change makes the following possible...
A second option
Instead of using Imports statements, you can use an XmlNamespaceManager like this:
Imports System.Xml
Imports System.Xml.XPath
Module Module1
Sub Main()
Dim x As XElement = <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<IntegrationGetEntitySetWithPacketLoginResponse xmlns:univera="http://integration.univera.com.tr">
<IntegrationGetEntitySetWithPacketLoginResult>
<ResultString>OK</ResultString>
<IsSuccess>true</IsSuccess>
<ResultEntitySet>
<GorevSonucBilgiler/>
<DistUnvan/>
<PaketAdi/>
<Warnings/>
<PaketTanimlar>
<clsPaketTanim>
<Kod xsi:nil="true"/>
<Tabloadi>CUSTOMVIEW_ENTVIEWFATURAGENERIC_OZGUN</Tabloadi>
<Viewadi>CUSTOMVIEW_ENTVIEWFATURAGENERIC_OZGUN</Viewadi>
<Yon xsi:nil="true"/>
<Kriter>"(LNGDISTKOD = 12) AND BYTTUR IN(0,1) AND (LNGYIL = 2018) AND (BYTDURUM = 0)"</Kriter>
<Durum xsi:nil="true"/>
</clsPaketTanim>
</PaketTanimlar>
<SatirBazliTransaction>false</SatirBazliTransaction>
<LogKategori>0</LogKategori>
<IntegrationGorevSonucTip>0</IntegrationGorevSonucTip>
<errorLoglist/>
<SCCall>false</SCCall>
<ReturnLoglist>false</ReturnLoglist>
<StokSil>false</StokSil>
<CustomData>
<ArrayOfClsDictionaryOfStringObject>
<clsDictionaryOfStringObject>
<Key>LNGYIL</Key>
<Value xsi:type="xsd:int">2018</Value>
</clsDictionaryOfStringObject>
<clsDictionaryOfStringObject>
<Key>LNGDISTKOD</Key>
<Value xsi:type="xsd:int">12</Value>
</clsDictionaryOfStringObject>
<clsDictionaryOfStringObject>
<Key>TXTDISTKOD</Key>
<Value xsi:type="xsd:string">SH012</Value>
</clsDictionaryOfStringObject>
<clsDictionaryOfStringObject>
<Key>TXTSTKOD</Key>
<Value xsi:type="xsd:string">SH010</Value>
</clsDictionaryOfStringObject>
</ArrayOfClsDictionaryOfStringObject>
</CustomData>
</ResultEntitySet>
</IntegrationGetEntitySetWithPacketLoginResult>
</IntegrationGetEntitySetWithPacketLoginResponse>
</soap:Body>
</soap:Envelope>
Dim doc = New XDocument(x)
Dim nt As NameTable = New NameTable()
Dim nsmgr As XmlNamespaceManager = New XmlNamespaceManager(nt)
nsmgr.AddNamespace("soap", "http://schemas.xmlsoap.org/soap/envelope/")
nsmgr.AddNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance")
nsmgr.AddNamespace("xsd", "http://www.w3.org/2001/XMLSchema")
nsmgr.AddNamespace("univera", "http://integration.univera.com.tr")
Dim a = doc.XPathSelectElements("/soap:Envelope/soap:Body/IntegrationGetEntitySetWithPacketLoginResponse/IntegrationGetEntitySetWithPacketLoginResult/ResultEntitySet/CustomData/ArrayOfClsDictionaryOfStringObject/clsDictionaryOfStringObject", nsmgr)
Dim lngyil2 = (
From v In a
Where v.XPathSelectElement("Key").Value = "LNGYIL"
Select v.XPathSelectElement("Value").Value
).Single()
Console.WriteLine(lngyil2)
Console.ReadLine()
End Sub
End Module
More work on the XPath query would let you get the value directly without the loop after it.
Refs:
- Imports Statement (XML Namespace)
- Can't get value with XPath in Soap XML
You need to code it to deal with the namespaces. One way is to use Imports statements like this:
Imports <xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
Imports <xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
Imports <xmlns:xsd="http://www.w3.org/2001/XMLSchema">
Imports <xmlns="http://integration.univera.com.tr">
Module Module1
Sub Main()
Dim x As XElement = <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<IntegrationGetEntitySetWithPacketLoginResponse xmlns="http://integration.univera.com.tr">
<IntegrationGetEntitySetWithPacketLoginResult>
<ResultString>OK</ResultString>
<IsSuccess>true</IsSuccess>
<ResultEntitySet>
<GorevSonucBilgiler/>
<DistUnvan/>
<PaketAdi/>
<Warnings/>
<PaketTanimlar>
<clsPaketTanim>
<Kod xsi:nil="true"/>
<Tabloadi>CUSTOMVIEW_ENTVIEWFATURAGENERIC_OZGUN</Tabloadi>
<Viewadi>CUSTOMVIEW_ENTVIEWFATURAGENERIC_OZGUN</Viewadi>
<Yon xsi:nil="true"/>
<Kriter>"(LNGDISTKOD = 12) AND BYTTUR IN(0,1) AND (LNGYIL = 2018) AND (BYTDURUM = 0)"</Kriter>
<Durum xsi:nil="true"/>
</clsPaketTanim>
</PaketTanimlar>
<SatirBazliTransaction>false</SatirBazliTransaction>
<LogKategori>0</LogKategori>
<IntegrationGorevSonucTip>0</IntegrationGorevSonucTip>
<errorLoglist/>
<SCCall>false</SCCall>
<ReturnLoglist>false</ReturnLoglist>
<StokSil>false</StokSil>
<CustomData>
<ArrayOfClsDictionaryOfStringObject>
<clsDictionaryOfStringObject>
<Key>LNGYIL</Key>
<Value xsi:type="xsd:int">2018</Value>
</clsDictionaryOfStringObject>
<clsDictionaryOfStringObject>
<Key>LNGDISTKOD</Key>
<Value xsi:type="xsd:int">12</Value>
</clsDictionaryOfStringObject>
<clsDictionaryOfStringObject>
<Key>TXTDISTKOD</Key>
<Value xsi:type="xsd:string">SH012</Value>
</clsDictionaryOfStringObject>
<clsDictionaryOfStringObject>
<Key>TXTSTKOD</Key>
<Value xsi:type="xsd:string">SH010</Value>
</clsDictionaryOfStringObject>
</ArrayOfClsDictionaryOfStringObject>
</CustomData>
</ResultEntitySet>
</IntegrationGetEntitySetWithPacketLoginResult>
</IntegrationGetEntitySetWithPacketLoginResponse>
</soap:Body>
</soap:Envelope>
Dim doc = New XDocument(x)
Dim q = doc.<soap:Envelope>.<soap:Body>.<IntegrationGetEntitySetWithPacketLoginResponse>.<IntegrationGetEntitySetWithPacketLoginResult>.<ResultEntitySet>.<CustomData>.<ArrayOfClsDictionaryOfStringObject>.<clsDictionaryOfStringObject>
Dim lngyil = (
From v In q
Where v.<Key>.Value = "LNGYIL"
Select v.<Value>.Value
).Single()
Console.WriteLine(lngyil)
Console.ReadLine()
End Sub
End Module
Outputs:
2018
P.S. I have a suspicion that xmlns="http://integration.univera.com.tr" is not valid, and it should be something like xmlns:univera="http://integration.univera.com.tr". That change makes the following possible...
A second option
Instead of using Imports statements, you can use an XmlNamespaceManager like this:
Imports System.Xml
Imports System.Xml.XPath
Module Module1
Sub Main()
Dim x As XElement = <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<IntegrationGetEntitySetWithPacketLoginResponse xmlns:univera="http://integration.univera.com.tr">
<IntegrationGetEntitySetWithPacketLoginResult>
<ResultString>OK</ResultString>
<IsSuccess>true</IsSuccess>
<ResultEntitySet>
<GorevSonucBilgiler/>
<DistUnvan/>
<PaketAdi/>
<Warnings/>
<PaketTanimlar>
<clsPaketTanim>
<Kod xsi:nil="true"/>
<Tabloadi>CUSTOMVIEW_ENTVIEWFATURAGENERIC_OZGUN</Tabloadi>
<Viewadi>CUSTOMVIEW_ENTVIEWFATURAGENERIC_OZGUN</Viewadi>
<Yon xsi:nil="true"/>
<Kriter>"(LNGDISTKOD = 12) AND BYTTUR IN(0,1) AND (LNGYIL = 2018) AND (BYTDURUM = 0)"</Kriter>
<Durum xsi:nil="true"/>
</clsPaketTanim>
</PaketTanimlar>
<SatirBazliTransaction>false</SatirBazliTransaction>
<LogKategori>0</LogKategori>
<IntegrationGorevSonucTip>0</IntegrationGorevSonucTip>
<errorLoglist/>
<SCCall>false</SCCall>
<ReturnLoglist>false</ReturnLoglist>
<StokSil>false</StokSil>
<CustomData>
<ArrayOfClsDictionaryOfStringObject>
<clsDictionaryOfStringObject>
<Key>LNGYIL</Key>
<Value xsi:type="xsd:int">2018</Value>
</clsDictionaryOfStringObject>
<clsDictionaryOfStringObject>
<Key>LNGDISTKOD</Key>
<Value xsi:type="xsd:int">12</Value>
</clsDictionaryOfStringObject>
<clsDictionaryOfStringObject>
<Key>TXTDISTKOD</Key>
<Value xsi:type="xsd:string">SH012</Value>
</clsDictionaryOfStringObject>
<clsDictionaryOfStringObject>
<Key>TXTSTKOD</Key>
<Value xsi:type="xsd:string">SH010</Value>
</clsDictionaryOfStringObject>
</ArrayOfClsDictionaryOfStringObject>
</CustomData>
</ResultEntitySet>
</IntegrationGetEntitySetWithPacketLoginResult>
</IntegrationGetEntitySetWithPacketLoginResponse>
</soap:Body>
</soap:Envelope>
Dim doc = New XDocument(x)
Dim nt As NameTable = New NameTable()
Dim nsmgr As XmlNamespaceManager = New XmlNamespaceManager(nt)
nsmgr.AddNamespace("soap", "http://schemas.xmlsoap.org/soap/envelope/")
nsmgr.AddNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance")
nsmgr.AddNamespace("xsd", "http://www.w3.org/2001/XMLSchema")
nsmgr.AddNamespace("univera", "http://integration.univera.com.tr")
Dim a = doc.XPathSelectElements("/soap:Envelope/soap:Body/IntegrationGetEntitySetWithPacketLoginResponse/IntegrationGetEntitySetWithPacketLoginResult/ResultEntitySet/CustomData/ArrayOfClsDictionaryOfStringObject/clsDictionaryOfStringObject", nsmgr)
Dim lngyil2 = (
From v In a
Where v.XPathSelectElement("Key").Value = "LNGYIL"
Select v.XPathSelectElement("Value").Value
).Single()
Console.WriteLine(lngyil2)
Console.ReadLine()
End Sub
End Module
More work on the XPath query would let you get the value directly without the loop after it.
Refs:
- Imports Statement (XML Namespace)
- Can't get value with XPath in Soap XML
edited Nov 26 '18 at 21:03
answered Nov 26 '18 at 18:57
Andrew MortonAndrew Morton
15.5k53151
15.5k53151
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53475992%2fcant-get-path-to-xml-element-in-soap%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
stackoverflow.com/questions/15933333/how-to-read-an-xml-file Find a Solution Here
– Prakash
Nov 26 '18 at 7:29
Thanks but No standart data in node tag.
– Hasan Fehmi B.
Nov 26 '18 at 7:46