Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XMlDoc to dataset hierarchy problem

Status
Not open for further replies.

AndyH1

Programmer
Jan 11, 2004
350
GB
On a C#.net site I've been asked to take over the programmer converts an XmlDoc to a dataset.

XmlDoc resultDoc = new XmlDoc();
...

resultDoc.LoadXml(text);
resultDoc.LoadXml(resultDoc.SelectSingleNode("//return").InnerXml);

DataSet ds = new DataSet();
ds.ReadXml((new StringReader(resultDoc.OuterXml)));

RadioButtonList1.DataSource = ds;
RadioButtonList1.DataTextField = "business";
RadioButtonList1.DataBind();

Ive seen this done before on a flat xml file, but the xml being used in this case (from a web service) is something like

<ibccompany:companyxmlns:ibccompany="IBC:company">
<companyID>
<localID>0x00000000000D0830</localID>
<BLID>S4D</BLID>
</companyID>
<business>Test</business>
...
<address>
<building>10</building>
<street />
...
</address>
<tel />
...
In his code he uses the line
RadioButtonList1.DataTextField = "business";
to get the business name. this is fine and works, but they want me to now use the building number instead of the business name. I can't think how I refer to this. Ive tried
RadioButtonList1.DataTextField = "building";
RadioButtonList1.DataTextField = "address/building"; // unlikely but in desperation tried
even
RadioButtonList1.DataTextField = "address";
in the hope it might give the entire address with tabs that I could strip the building out of but it doesn't recognise

Is there anyway I can refer to the building field in the ds, or is it simply not converted

Thanks
AndyH1
 
datasets are tabular data. xml can be tabular if structured that way. however this xml is hierarchical. certain controls can only handle tabular data (grid, dropdown, etc.) while other handle hierarchical (menu control). since you are working with a radio button list you need to convert the hierarchy to tabular data (load a datatable manually) then bind the data table to the control.


Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
faq732-7259
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top