XML challenge!

R

Random

Trying to solicit some quick advice on my procedure architecture so I don't
have to waste too much time with trying different objects. I'm still
unfamiliar with a lot of the new XML parsing/manipulation in .NET, so I
could really use the help.

I have a set of xml files, all in the same directory, adhering to the same
schema. I want to implement a keyword search feature, and display the
results in a DataGrid control (or GridView, DetailsView, or FormView control
for .NET 2.0), with the results containing a hyperlink specifying the xml
document name and the node name and/or parent node name of the attribute
value or node value that matches the keyword(s) being searched (these are
the peices of information I need in the query string to parse and display
the xml data on another page).

To do this, I thought I'd iterate through the files in the directory, apply
a small set of xpath queries to return an XmlNodeList, that I would then add
to either a custom business object or xml document, and then DataBind the
result to the DataGrid.

The sole problem I see with this method is that my XmlNodeList would not
contain the info I might require on the parent node, and this would
therefore be unavailable for my results.

Should I be using something other than a custom xml document, or
XmlNodeList? What other methods might work more efficiently?
 
M

Marshal Antony

Hi,
One easy way is to load your XML file into a dataset and apply your
filter to the data table.

DataSet ds= new DataSet ( );

// Read your xml file into a dataset
ds.ReadXml ( Server.MapPath ( "/path/test.xml" ) );
To do the filtering :
DataRow[] dataRows =
ds.Tables[0].Select( select expression);
then bind to the datagrid

Hope this helps.
Regards,
Marshal Antony
..NET Developer
 
R

Random

But if I do this how can I get more than one xml file into the dataset? I
could, I suppose, collect and concatenate all the xml files in the directory
into one master xml document, but then how could I structure the filter to
search in both node and attribute values at the same time?


Marshal Antony said:
Hi,
One easy way is to load your XML file into a dataset and apply your
filter to the data table.

DataSet ds= new DataSet ( );

// Read your xml file into a dataset
ds.ReadXml ( Server.MapPath ( "/path/test.xml" ) );
To do the filtering :
DataRow[] dataRows =
ds.Tables[0].Select( select expression);
then bind to the datagrid

Hope this helps.
Regards,
Marshal Antony
.NET Developer





Random said:
Trying to solicit some quick advice on my procedure architecture so I don't
have to waste too much time with trying different objects. I'm still
unfamiliar with a lot of the new XML parsing/manipulation in .NET, so I
could really use the help.

I have a set of xml files, all in the same directory, adhering to the
same
schema. I want to implement a keyword search feature, and display the
results in a DataGrid control (or GridView, DetailsView, or FormView control
for .NET 2.0), with the results containing a hyperlink specifying the xml
document name and the node name and/or parent node name of the attribute
value or node value that matches the keyword(s) being searched (these are
the peices of information I need in the query string to parse and display
the xml data on another page).

To do this, I thought I'd iterate through the files in the directory, apply
a small set of xpath queries to return an XmlNodeList, that I would then add
to either a custom business object or xml document, and then DataBind the
result to the DataGrid.

The sole problem I see with this method is that my XmlNodeList would not
contain the info I might require on the parent node, and this would
therefore be unavailable for my results.

Should I be using something other than a custom xml document, or
XmlNodeList? What other methods might work more efficiently?
 
M

Marshal Antony

You can add multiple datatables to the dataset,so you can read multiple xml
files added to the same dataset as data tables.
Then you can loop through ther datatables collection in the dataset and
perform the search.
Hope this helps
Regards,
Marshal Antony
..NET Developer


Random said:
But if I do this how can I get more than one xml file into the dataset? I
could, I suppose, collect and concatenate all the xml files in the directory
into one master xml document, but then how could I structure the filter to
search in both node and attribute values at the same time?


Marshal Antony said:
Hi,
One easy way is to load your XML file into a dataset and apply your
filter to the data table.

DataSet ds= new DataSet ( );

// Read your xml file into a dataset
ds.ReadXml ( Server.MapPath ( "/path/test.xml" ) );
To do the filtering :
DataRow[] dataRows =
ds.Tables[0].Select( select expression);
then bind to the datagrid

Hope this helps.
Regards,
Marshal Antony
.NET Developer





Random said:
Trying to solicit some quick advice on my procedure architecture so I don't
have to waste too much time with trying different objects. I'm still
unfamiliar with a lot of the new XML parsing/manipulation in .NET, so I
could really use the help.

I have a set of xml files, all in the same directory, adhering to the
same
schema. I want to implement a keyword search feature, and display the
results in a DataGrid control (or GridView, DetailsView, or FormView control
for .NET 2.0), with the results containing a hyperlink specifying the xml
document name and the node name and/or parent node name of the attribute
value or node value that matches the keyword(s) being searched (these are
the peices of information I need in the query string to parse and display
the xml data on another page).

To do this, I thought I'd iterate through the files in the directory, apply
a small set of xpath queries to return an XmlNodeList, that I would
then
add
to either a custom business object or xml document, and then DataBind the
result to the DataGrid.

The sole problem I see with this method is that my XmlNodeList would not
contain the info I might require on the parent node, and this would
therefore be unavailable for my results.

Should I be using something other than a custom xml document, or
XmlNodeList? What other methods might work more efficiently?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top