XML into DataSet - How to nav through Data

Hi.  I need some help.

I have an xml file what will contain hundreds of groups and will have an associated xsd.

My overall goal is to have a web application that allows a user to input a groupID from a webform, the application will than find 
that groupID in the xml file and display all the related information for that group only.

I have read my xml into a DataSet and have been able to successful find groupID and display some of the information for that 
particular group.

But I have been unable to navigate to the groupsItems node and subsequently the details of each groupItem found in 
groupItems/groupItem.

I have used the following to retrieve BDate, groupID groupName,  - but have been able to navigate deeper.
.....
string businessDate = ds.Tables[0].Rows[0]["BDate"].ToString();
.....

foreach (DataRow dr in ds.Tables[1].Rows)
{
	string drGroupID = dr["groupID"].ToString();
	string drgroupname = dr["groupName"].ToString();
	if (drGroupID == groupID)
	{
		Console.WriteLine (businessDate);
		Console.WriteLine (drgroupname);
//Want to naviagte to groupItems/groupItem and print out all data found there.
			
	}
}

.....
I have tried the GetChildRows, but have been unsuccessful, and various other methods, but nothing has worked.

Thanks in advance for any help.

<?xml version="1.0" ?>
<xs:schema id="NewDataSet" targetNamespace="http://tempuri.org/asucPartial.xsd" xmlns:mstns="http://tempuri.org/asucPartial.xsd"
	xmlns="http://tempuri.org/asucPartial.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema"
	xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" attributeFormDefault="qualified" elementFormDefault="qualified">

<xs:element name="AATop">
	<xs:complexType>
		<xs:sequence>
			<xs:element name="BDate" type="xs:string" minOccurs="0" />
			<xs:element name="Group" minOccurs="0" maxOccurs="unbounded">
				<xs:complexType>
					<xs:sequence>
						<xs:element name="groupID" type="xs:string" minOccurs="0" />
						<xs:element name="groupName" type="xs:string" minOccurs="0" />
						<xs:element name="groupItems" minOccurs="0" maxOccurs="unbounded">
							<xs:complexType>
								<xs:sequence>
									<xs:element name="groupItem" minOccurs="0" maxOccurs="unbounded">											<xs:complexType>
											<xs:sequence>
												<xs:element name="Description" type="xs:string" minOccurs="0" msdata:Ordinal="0" />
												<xs:element name="MonthToDate" type="xs:string" minOccurs="0" msdata:Ordinal="1" />
												<xs:element name="YearToDate" type="xs:string" minOccurs="0" msdata:Ordinal="2" />
												<xs:element name="YTDemCumbrnce" type="xs:string" minOccurs="0" msdata:Ordinal="3" />
												<xs:element name="AnnualBudget" type="xs:string" minOccurs="0" msdata:Ordinal="4" />
												<xs:element name="AnnualVar" type="xs:string" minOccurs="0" msdata:Ordinal="5" />
												<xs:element name="PercentUsed" type="xs:string" minOccurs="0" msdata:Ordinal="6" />
											</xs:sequence>
											<xs:attribute name="type" form="unqualified" type="xs:string" />
										</xs:complexType>
									</xs:element>
								</xs:sequence>
							</xs:complexType>
						</xs:element>
					</xs:sequence>
				</xs:complexType>
			</xs:element>
		</xs:sequence>
	</xs:complexType>
	<xs:key name="groupID" msdata:PrimaryKey="true">
		<xs:selector xpath=".//mstns:Group" />
		<xs:field xpath="mstns:groupID" />
	</xs:key>
</xs:element>
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:EnforceConstraints="False">
	<xs:complexType>
		<xs:choice maxOccurs="unbounded">
			<xs:element ref="AATop" />
		</xs:choice>
	</xs:complexType>
</xs:element>
</xs:schema>

0
elvisktr (6)
8/25/2005 5:08:37 PM
dotnet.xml 7266 articles. 0 followers. Follow

1 Replies
422 Views

Similar Articles

[PageSpeed] 33

I was able to solve my problem by using Node and NodeLists and using XPath to find the node I needed.



K riley wrote:
> Hi.  I need some help.
> 
> I have an xml file what will contain hundreds of groups and will have an 
> associated xsd.
> 
> My overall goal is to have a web application that allows a user to input 
> a groupID from a webform, the application will than find that groupID in 
> the xml file and display all the related information for that group only.
> 
> I have read my xml into a DataSet and have been able to successful find 
> groupID and display some of the information for that particular group.
> 
> But I have been unable to navigate to the groupsItems node and 
> subsequently the details of each groupItem found in groupItems/groupItem.
> 
> I have used the following to retrieve BDate, groupID groupName,  - but 
> have been able to navigate deeper.
> ....
> string businessDate = ds.Tables[0].Rows[0]["BDate"].ToString();
> ....
> 
> foreach (DataRow dr in ds.Tables[1].Rows)
> {
>     string drGroupID = dr["groupID"].ToString();
>     string drgroupname = dr["groupName"].ToString();
>     if (drGroupID == groupID)
>     {
>         Console.WriteLine (businessDate);
>         Console.WriteLine (drgroupname);
> //Want to naviagte to groupItems/groupItem and print out all data found 
> there.
>            
>     }
> }
> 
> ....
> I have tried the GetChildRows, but have been unsuccessful, and various 
> other methods, but nothing has worked.
> 
> Thanks in advance for any help.
> 
> <?xml version="1.0" ?>
> <xs:schema id="NewDataSet" 
> targetNamespace="http://tempuri.org/asucPartial.xsd" 
> xmlns:mstns="http://tempuri.org/asucPartial.xsd"
>     xmlns="http://tempuri.org/asucPartial.xsd" 
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
>     xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" 
> attributeFormDefault="qualified" elementFormDefault="qualified">
> 
> <xs:element name="AATop">
>     <xs:complexType>
>         <xs:sequence>
>             <xs:element name="BDate" type="xs:string" minOccurs="0" />
>             <xs:element name="Group" minOccurs="0" maxOccurs="unbounded">
>                 <xs:complexType>
>                     <xs:sequence>
>                         <xs:element name="groupID" type="xs:string" 
> minOccurs="0" />
>                         <xs:element name="groupName" type="xs:string" 
> minOccurs="0" />
>                         <xs:element name="groupItems" minOccurs="0" 
> maxOccurs="unbounded">
>                             <xs:complexType>
>                                 <xs:sequence>
>                                     <xs:element name="groupItem" 
> minOccurs="0" 
> maxOccurs="unbounded">                                            
> <xs:complexType>
>                                             <xs:sequence>
>                                                 <xs:element 
> name="Description" type="xs:string" minOccurs="0" msdata:Ordinal="0" />
>                                                 <xs:element 
> name="MonthToDate" type="xs:string" minOccurs="0" msdata:Ordinal="1" />
>                                                 <xs:element 
> name="YearToDate" type="xs:string" minOccurs="0" msdata:Ordinal="2" />
>                                                 <xs:element 
> name="YTDemCumbrnce" type="xs:string" minOccurs="0" msdata:Ordinal="3" />
>                                                 <xs:element 
> name="AnnualBudget" type="xs:string" minOccurs="0" msdata:Ordinal="4" />
>                                                 <xs:element 
> name="AnnualVar" type="xs:string" minOccurs="0" msdata:Ordinal="5" />
>                                                 <xs:element 
> name="PercentUsed" type="xs:string" minOccurs="0" msdata:Ordinal="6" />
>                                             </xs:sequence>
>                                             <xs:attribute name="type" 
> form="unqualified" type="xs:string" />
>                                         </xs:complexType>
>                                     </xs:element>
>                                 </xs:sequence>
>                             </xs:complexType>
>                         </xs:element>
>                     </xs:sequence>
>                 </xs:complexType>
>             </xs:element>
>         </xs:sequence>
>     </xs:complexType>
>     <xs:key name="groupID" msdata:PrimaryKey="true">
>         <xs:selector xpath=".//mstns:Group" />
>         <xs:field xpath="mstns:groupID" />
>     </xs:key>
> </xs:element>
> <xs:element name="NewDataSet" msdata:IsDataSet="true" 
> msdata:EnforceConstraints="False">
>     <xs:complexType>
>         <xs:choice maxOccurs="unbounded">
>             <xs:element ref="AATop" />
>         </xs:choice>
>     </xs:complexType>
> </xs:element>
> </xs:schema>
> 
0
elvisktr (6)
8/31/2005 5:36:44 AM
Reply:

Similar Artilces:

can i edit only a selected range of data in an excel chart?
I perform a lot of tests that involve changing changing an element during the run and observing the effects over time and it would be extremely useful if I could create a trendline that covered only the desired range of data, rather than spanning the entire chart, without having to go in, find the data range and plot it in a chart of its own. Is there any way to do this? I'm currently using Office 2003. Let's say the dates are in column A, the y-values in B In column C type a 1 next to the cells you want plotted In D2 (I will assume the first row has headers) , enter =IF...

Importing external data in plain text row format
I have data in the following format: -------------------Begin Sample Data---------------------- Fernando E. Amuchastegui Office of the County Attorney 115 S. Andrews Avenue Suite 423 Fort Lauderdale 33301 954-357-7600 Voice 954-357-7641 Fax famuchastegui@broward.org Ronald J. Anania Law Offices of Ronald J. Anania 10910 S W 10th Court Davie 33324 954-476-9616 Voice 954-476-9693 Fax law1492aol.com Eric J. Anders Haley Sinagra Paul & Toland, P.A. 100 SE 3 Avenue Suite 1900 Fort Lauderdale 33394 954-467-1300 Voice 954-467-1372 Fax eanders@hsptlaw.com Hal B. Anderson Billing Cochran H...

Olap data views
Hello, I've deployed a farm solution with SQL Server 2005, Project server 2007 and windows Server 2003 SP2. I configured Project Server 2007 default cube sucsessfuly and I can create views and see them in PWA Data Analysis. I created a new project Data Analysis Services in Visual Studio. I deployed it remotely and I can see the New cube deployed if I connect to Analysis Services SQL Services Management Studio. Problem start in PWA, because i can't see the newly deployed cube. I only see the default cube created in pwa interface if i go to "server settings...

copying data validation to another workbook
am i able to copy my data validation cell that i created in one workbook over to a new excel file not associated with the original. I have no problem copying validation from one area to another within a workbook but can't seem to bring the validation commands over to a new file. Just select the column or range on which you are having the Data Validation and give Cntrl+C and Press Cntrl+N to open a new workbook or open the workbook on which do you want to paste the Data Validation. Now select the Column or Range of cells and do Right Click>>Paste Special>>select...

how to query data as of a specific date
I'm relatively new at access so I'm hoping someone might be able to give me an efficient way to perform the following; I'm trying to retrieve historical records as of a specific date from a table. For example, I need to retrieve the status of a group of employees as of 02/15/2006. However, an employee's history records for the status field are, 01/01/2005 - FT, 02/01/2006 - PT, 01/15/2007 - FT . What's the best way to query the tbl so that PT is returned when I run the query with an "as of" date of 2/15/2006? Base query would be as follows. SELECT Emplo...

using Vlookup to validate data
I have 2 spreadsheets with names and email addresses - File 1: 150 records File 2: 63000 records I need to check if each of the emails on file 1 are there in file 2 or not. If it is there it shoul show "yes" else show "no" when I do a Vlookup it gives me the email ids in the cell - I am not able to show a 'yes' or 'no' so I guess this will hav eto be a combination of vlookup and IF statement.....any ideas? Hi No need for a slow lookup. Assuming data in column A of both sheets On sheet1 in B1 =IF(COUNTIF(Sheet2!A:A,A1),"yes&q...

Map fortnightly data to months
Hi All, I've puzzled over whether I can accomplish what I want using just a query (or a set of queries), and came to the conclusion that I couldn't - but that doesn't mean it can't be done. I'm trying to map a set of fortnightly salary data into months in a financial year. I have the following tables and fields: tblStaffEffort FY - integer Period - integer (number from 1 to 27 - only gets to 27 about one year in 11) Hours - double Cost - currency ... tblMDS (monthly datasets) FY - integer Mnth - integer (1-12, for Jan ...

Outlook sharing data
A friend has a Novell 4.11 office network with several PCs running Windows 98 SE. I guess he means they have a Novell server and other PCs running Windows 98 SE. One PC has a broadband modem and runs MS Outlook for email. What would it take to give Outlook running on one or more of the other PCs access to the incoming emails and the ability to send emails. I think the idea is that there would be only one email address but several people could look through the incoming emails. -- Brian Gregory. (In the UK) ng@bgdsv.co.uk To email me remove the letter vee. Dear Brian, What Outloo...

data migration framework errors
We are using the data migration framework to migrate into a fresh CRM 1.0 installation. We are at the step where we run the CDFMigration Tool. It runs and completes with no errors. It only migrates contacts, no accounts, incidents, etc. Steps 1. A clean restore of the cdf_mscrm, and CRM databases(which were backed up right after we finished cleaning the data, before we started to migrate) 2. The cdf_"entity"_info table for account, activity, annotation, contact, incident were empty: followed TechKBArticle #31094 from MSBTechKnowledge which said to run: Declare @Id As int Declar...

Exported File truncating cell data after 255 characters
I have exported a file in Excel format from MS Access. When I open the file in Excel, the cells containing greater than 255 characters have been truncated. Any way around this? Excel will not display any characters if you put more than 255 in a cell. Instead you'll get only # signs. So..exporting more than 255 (or maybe even 254) in a field is not likely to help you. How many characters in the fields you're trying to export? If not too many more than the 255 limit - you could use a query to break it into two columns - first one getting the LEFT([textfield],200) and the next...

Graphs/Charts by country. Same Graph, different Source Data
Hi I have sales information for 5 countries, each on separate sheets ( the sheets are identical in format) . I have made graphs for the first country, and I want to copy them to the other countries, and change the references to pick up the right country information. Is there a quick way of doing this or do i have to go into source information for each series for each graph and change the sheet( country ) reference I asppreciate any answers to this as atthe moment I've spent the better part of a day changing sheet references Rgds Dan ...

"File Error: Data May Be Lost" error when opening workbook saved in Mac
When I open in Excel 2007 for Windows workbook with charts saved in Mac OS, I see the message "File Error: Data May Be Lost". In Excel 2003 for Windows this message appears as many times as many sheets there are in workbook. Maybe someone knows what's the reason? Unfortunately you haven't provided the info needed... "Mac OS" means very little. The question is "What version of Mac Excel are you using, what file format are the files saved as & what type of content is in the files?" In general, what you're running into is that Excel 2003 &a...

SQL to XML to XSL
Hi there, I'm a little stuck and would appreciate ANY help getting over this hurdle. Let's say that I've got a SQL Server stored procedure that includes FOR XML AUTO, ELEMENTS And that within a .Net Web Form, I'd like to call that stored procedure and then apply an .XSLT file to it. What would the code look like to do that? Any help would be GREATLY appreciated. Thanks, _K http://www.wiley.com/extras Look for ADO.NET and XML: ASP.NET on the Edge Download the sample code for the last three chapters. There is an example in there on how to do an XSLT transform directl...

how can i make a line chart from matrix(both row and col) of data
Select the data, and create the chart. By default, Excel is likely to use the first column as X values (or category labels) and the first row as series names, if the data is plotted by column. If Excel has trouble with this, clear the top left cell of the range (the intersection of series names and category labels/X values) and try again. - Jon ------- Jon Peltier, Microsoft Excel MVP Tutorials and Custom Solutions Peltier Technical Services, Inc. - http://PeltierTech.com _______ "Gourav" <Gourav@discussions.microsoft.com> wrote in message news:CEA158CD-95F4-4903-BFBB...

Putting an XML document in a TreeView.
I would like to put an XML document into a Windows TreeView. I have started with XmlTextReader and seem to get stuck with all of the different Read/Move commands available. I was wondering if someone else has already gone through the pain of descending through an XML document either printing or adding the attribute and element values and names to a TreeView? It would just save me some time as I will have to do some trial and error to get it to work. Thank you. Kevin Hello! Maybe you could use XmlDocument, it should be easy to convert from one tree-like structure to another. (You'...

There is an error in XML document (1, 43461).
Hi, I'm developing a web Method that takes the entity name as string Input and return the primary field of the entity. I tried the web method with the incident entity and it returns to me IncidentID as a primary field but when I try it with account or contact entity it return the following error : System.Xml - : There is an error in XML document (1, 43461). System.FormatException: Input string was not in a correct format. at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) at System.Number....

Message queue data file error ID 4083
Unable to delivered outbound message. Please Help me. ...

DDE Data analysis
Hello I have a sheet which is connected via DDE, i.e. some cells get updated via API. I would like to analyse this data for high and low values. How can I save this data in other cells or print a chart (dynamicly). To use =MAX() or =MIN() is not good as it is overwritten with new data. Any ideas, links, etc. are welcome. Daniel ...

how to find last cell in column with data
I have a very simple checkbook register. I would like to be able to display the ending balance in a specific cell at the top of the sheet. How can I do this? Thanks Let's say your balance is in column A from A2 to somewhere below. Put in A1 =LOOKUP(2,1/(A2:A65356>0),A2:A65356) (suggested by Sandy Mann) -- Gary's Student "keyser_Soze@usa.com" wrote: > I have a very simple checkbook register. I would like to be able to > display > the ending balance in a specific cell at the top of the sheet. How can > I do this? > > Thanks > > Gary&#...

xml schema and 2D arrays
Hi, I have got to transfer some data into a c# project from an old one that was written in delphi. I am new to XML, but it looks idea for transfering this data around. I have written a schema for this data using the tools in visual studio, my problem is that i dont know how to represent the arrays in the schema. These arrays a dynamic, so i dont know how big they are at design-time. Is it possible to represent this kind of data in XML? thanks in advance Neil yes it is possible. I suggest you use the xsd.exe tool as a design aid. Build a class in C#, then compile it into a DLL. Run xsd /...

Using C# to read mass data from Excel 2003
Hi all�� I am using C# to read data from Excel 2003, However, I found the method I taken is too inefficient. Read a 250X250 sized matrix will take several minutes. May u provide me some high efficient method to solve mass data reading problem��Thanks int ColNum = mySheet.UsedRange.Columns.Count; int RowNum = mySheet.UsedRange.Rows.Count; Range range = mySheet.get_Range(mySheet.Cells[1, 1], mySheet.Cells[RowNum, ColNum]); ... for (int i = 1; i <= RowNum; ++ i) { DataRow dr; dr = dt.NewRow(); for (int j = 1; j <= ColNum; ++ j) { dr[j - 1] = ((...

Data change as scrolling
Hi, Just been told how to use Freeze pane option so my days of the week scroll down the worksheet. My A column has the months in it. I.E I have January in A1 and April in A10. B1, B2 etc has the days of the week. How do I get the A1 cell to change to a different month as the row scroll down to it? Thanks Have you thought about designing the w/s differently? If you list all months in col a a1=Jan a2=Feb etc then have the days in b,c,d etc The way I understand it your sheet will have all the data in cols a & b. It won't look pretty and by my suggestion you should ...

accessing excel combo box control data from vb .net
Hi, I have a spread sheet with a EMBED combo box. I select an item in the combo box and save the sheet. Now i am reading the spreadsheet values from VB .NET using Microsoft.Office.Interop library. I am able to get the values of regular cell in the sheet. Can anyone tell me how to get the data of the combo box from vb .net. Any help is appreciated. Prn See your other thread -- Regards Ron de Bruin http://www.rondebruin.nl "CoolCyber" <coolcyber+microsoft@gmail.com> wrote in message news:%237VfR$%231FHA.2132@TK2MSFTNGP15.phx.gbl... > Hi, > > I have a spread s...

Create a PPT slide from excel data
Hello! I have an Excel sheet with five columns and hundreds of rows. Also have a power point template slide, with dedicated spaces for each column as the Excel file. What I wanna do is to create one slide for each one of my Excel rows. It seems easy to create a loop and copy anywhere else, but I don't know how to communicate Excel and Power Point. Thanks in advance for your time. Eduardo Consider adding tabs and use new tabs as PPT report. Easier to link, avoids problems, etc. I did this and it was a lot easier, EVEN held up to light so rows and columns matched. No typos, no pr...

How does InnerText appear in a Dataset loaded by .ReadXml/.ReadXmlSchema
I've got an XML document I am loading into a dataset using ..ReadXml/.ReadXmlSchema. The dataset looks perfect and I can bind it to a datagrid and elements appear as tables and attributes appear as columns. The only problem I have is InnerText values for example: <outer> <tag name="blah"> ... <function> some text here </function> <validate> some text here </validate> ... </tag> <tag ... </tag> </outer> Even though the <function> and <validate> elements show as child tables (with an _Id to ...