EDN Admin
Well-known member
<pre class="prettyprint <?xml version="1.0" encoding="utf-8" ?>
<reply>
<ns1:BODY xmlns:jms1="http://www.abc.com/namespaces/tnt/plugins/jms" xmlns:ns0="http://xmlns.ud.ea/IAE/RESPONSE_EAI" xmlns:ns1="http://xmlns.ud.ea/IAE/DU_BUSINESS_SERVICE_REPLY
<ns1:RESPONSE xmlns:ns1="http:/xmlns.ud.ea/UDSERVICE/Business/LOG_INVOICE_DELIVERY_RESPONSE
<ns1:EMP_CODE>71193</ns1:EMP_CODE>
<ns1:JOIN_DATE>17/03/2012 00:00:00 GST</ns1:JOIN_DATE>
<ns1:AGE>27</ns1:AGE>
</ns1:RESPONSE>
</ns1:BODY>
</reply>[/code]
So, the following element EMP_CODE needs to be retieved, i have used XDocument, XElement to retireave the data
<pre class="prettyprint XNamespace _ResponseNamespace1 ="http://xmlns.ud.ea/IAE/DU_BUSINESS_SERVICE_REPLY";
XNamespace _ResponseNamespace2 ="http://xmlns.ud.ea/UDSERVICE/Business/LOG_INVOICE_DELIVERY_RESPONSE";
XElement _check1 = xmlDocResponse
.Element("reply")
.Element(_ResponseNamespace1 + "BODY");
XElement _check2 = xmlDocResponse
.Element("reply")
.Element(_ResponseNamespace1 + "BODY")
.Element(_ResponseNamespace2 + "RESPONSE");[/code]
<br/>
_check1 works fine but for _check2, it gives null which tells me that there is some issue with the namespace; could you please help me to fix this?
View the full article
<reply>
<ns1:BODY xmlns:jms1="http://www.abc.com/namespaces/tnt/plugins/jms" xmlns:ns0="http://xmlns.ud.ea/IAE/RESPONSE_EAI" xmlns:ns1="http://xmlns.ud.ea/IAE/DU_BUSINESS_SERVICE_REPLY
<ns1:RESPONSE xmlns:ns1="http:/xmlns.ud.ea/UDSERVICE/Business/LOG_INVOICE_DELIVERY_RESPONSE
<ns1:EMP_CODE>71193</ns1:EMP_CODE>
<ns1:JOIN_DATE>17/03/2012 00:00:00 GST</ns1:JOIN_DATE>
<ns1:AGE>27</ns1:AGE>
</ns1:RESPONSE>
</ns1:BODY>
</reply>[/code]
So, the following element EMP_CODE needs to be retieved, i have used XDocument, XElement to retireave the data
<pre class="prettyprint XNamespace _ResponseNamespace1 ="http://xmlns.ud.ea/IAE/DU_BUSINESS_SERVICE_REPLY";
XNamespace _ResponseNamespace2 ="http://xmlns.ud.ea/UDSERVICE/Business/LOG_INVOICE_DELIVERY_RESPONSE";
XElement _check1 = xmlDocResponse
.Element("reply")
.Element(_ResponseNamespace1 + "BODY");
XElement _check2 = xmlDocResponse
.Element("reply")
.Element(_ResponseNamespace1 + "BODY")
.Element(_ResponseNamespace2 + "RESPONSE");[/code]
<br/>
_check1 works fine but for _check2, it gives null which tells me that there is some issue with the namespace; could you please help me to fix this?
View the full article