locked
How to get child rows of XML into dataset RRS feed

  • Question

  • I have XML schema that looks like this:

    <deals>
      <deal>
        <dealid></dealid>
        <agentid></agentid>
        <brokername></brokername>
        <flobcd></flobcd>
        <dealname></dealname>
        <buildingname></buildingname>
        <grosscommissiontoregion></grosscommissiontoregion>
        <probability></probability>
        <share></share>
        <split></split>
        <executiondate></executiondate>
        <dealstatus></dealstatus>
        <accountcd></accountcd>
        <cityname></cityname>
        <transactionstatusname></transactionstatusname>
        <size></size>
        <sizelabelname></sizelabelname>
        <representtypename></representtypename>
        <customer1></customer1>
        <customer2></customer2>
        <dealvalue></dealvalue>
        <dealvaluelabel></dealvaluelabel>
        <revenuetypeid></revenuetypeid>
        <revenuetypename></revenuetypename>
        <leasetypename></leasetypename>
        <propertytypecd></propertytypecd>
        <dealsource></dealsource>
        <dealcontact></dealcontact>
        <dealnotes>
              <dealnote></dealnote>
              <dealnotedate></dealnotedate>
              <dealnoteagentid></dealnoteagentid>
        </dealnotes>
      </deal>
    </deals>

    My issue occurs on getting dealnotes.  If I have mulitple deal notes for one deal and I convert the XML to a dataset, I only get the first one when I call the method GetChildRows("deal_dealnotes") method.  

    Why is this?  What am I doing wrong?


    Thursday, July 5, 2012 8:08 PM

Answers

  • I think that could be your XML structure issue.

    The one of proper ways will be following and GetChildRows should return 2 dealnotes

    <deals>
      <deal>
        <dealid></dealid>
        ...
    	...
        <dealcontact></dealcontact>
        <dealnotes>
              <dealnote>1a</dealnote>
              <dealnotedate>1b</dealnotedate>
              <dealnoteagentid>1c</dealnoteagentid>
        </dealnotes>
    	<dealnotes>
              <dealnote>2a</dealnote>
              <dealnotedate>2b</dealnotedate>
              <dealnoteagentid>2c</dealnoteagentid>
        </dealnotes>
      </deal>
    </deals>

    Hope this helps.
    • Marked as answer by Allen_MSDN Monday, July 16, 2012 3:27 AM
    Friday, July 6, 2012 4:27 AM
  • Yea easier is to do

    TheDataSet.ReadXML(ThePathOfTheXMLFile or the name of the string which contains the XML)


    Success
    Cor

    TheDataSet.ReadXML(ThePathOfTheXMLFile or the name of the string which contains the XML)

    TheDataSet.ReadXML(ThePathOfTheXMLFile or the name of the string which contains the XML)
    • Edited by Cor Ligthert Friday, July 6, 2012 5:58 AM
    • Marked as answer by Allen_MSDN Monday, July 16, 2012 3:27 AM
    Friday, July 6, 2012 5:57 AM

All replies

  • I think that could be your XML structure issue.

    The one of proper ways will be following and GetChildRows should return 2 dealnotes

    <deals>
      <deal>
        <dealid></dealid>
        ...
    	...
        <dealcontact></dealcontact>
        <dealnotes>
              <dealnote>1a</dealnote>
              <dealnotedate>1b</dealnotedate>
              <dealnoteagentid>1c</dealnoteagentid>
        </dealnotes>
    	<dealnotes>
              <dealnote>2a</dealnote>
              <dealnotedate>2b</dealnotedate>
              <dealnoteagentid>2c</dealnoteagentid>
        </dealnotes>
      </deal>
    </deals>

    Hope this helps.
    • Marked as answer by Allen_MSDN Monday, July 16, 2012 3:27 AM
    Friday, July 6, 2012 4:27 AM
  • Yea easier is to do

    TheDataSet.ReadXML(ThePathOfTheXMLFile or the name of the string which contains the XML)


    Success
    Cor

    TheDataSet.ReadXML(ThePathOfTheXMLFile or the name of the string which contains the XML)

    TheDataSet.ReadXML(ThePathOfTheXMLFile or the name of the string which contains the XML)
    • Edited by Cor Ligthert Friday, July 6, 2012 5:58 AM
    • Marked as answer by Allen_MSDN Monday, July 16, 2012 3:27 AM
    Friday, July 6, 2012 5:57 AM