0

I have an xml document that looks like this:

<OUTPUT version="2.0">
    <RESPONSE>
        <LOAN_DATA 
            loan_id="xxxx" 
            loan_number="1111" 
            loan_type="HE" 
            status_code="OK">
        <![CDATA[<MORTGAGE_LOAN xmlns="http://www.something.com/CLF" version="1.0">
            <APPLICANTS>
                <APPLICANT 
                    is_declined="N" 
                    first_name="MARISOL" 
                    last_name="TESTCASE" 
                    m_initial="L" 
                    middle_name="L" 
                    ssn="000000001" >
                              </APPLICANT>
            </APPLICANTS>
                   </MORTGAGE_LOAN>]]>
        </LOAN_DATA>
    </RESPONSE>
</OUTPUT>
I can successfully read down to the CData section and can even access the CData section using the following:

string cData = "";
            XmlDocument xDoc = new XmlDocument();
            xDoc.LoadXml(loanData);

            XmlNode node = xDoc.DocumentElement.SelectSingleNode(@"RESPONSE/LOAN_DATA");
            XmlNode childNode = node.ChildNodes[0];
            if (childNode is XmlCDataSection)
            {
                XmlCDataSection cdataSection = childNode as XmlCDataSection;
                cData = cdataSection.Value;
            }

cData now holds:

<MORTGAGE_LOAN xmlns="http://www.something.com/CLF" version="1.0">
            <APPLICANTS>
                <APPLICANT 
                    is_declined="N" 
                    first_name="MARISOL" 
                    last_name="TESTCASE" 
                    m_initial="L" 
                    middle_name="L" 
                    ssn="000000001" >
                              </APPLICANT>
            </APPLICANTS>
                   </MORTGAGE_LOAN>

What I want to do is to treat this as a new xml document and read it accordingly. When using the following node is always null. I've tried several versions of the xpath and it always returns null.

XmlDocument cDataDoc = new XmlDocument();
cDataDoc.LoadXml(c//node is always null here
 XmlNode node =cDataDoc.DocumentElement.SelectSingleNode("MORTGAGE_LOAN/APPLICANTS/APPLICANT");

Any help would be great. Thanks ....

2
Contributors
1
Reply
15
Views
4 Years
Discussion Span
Last Post by LastMitch
0

What I want to do is to treat this as a new xml document and read it accordingly. When using the following node is always null. I've tried several versions of the xpath and it always returns null.

If you want to read this xml document then used these links as a reference (there's nothing with your ASP.net code):

http://www.mssqltips.com/sqlservertip/1524/reading-xml-documents-using-linq-to-xml/

http://i-think22.net/archives/2009/02/25/xml-made-easy-with-linq-to-xml/

http://www.codeproject.com/Articles/209954/Parsing-XML-file-in-VB-NET-using-DOM

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.