By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,028 Members | 1,784 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,028 IT Pros & Developers. It's quick & easy.

XML Parsing in C#, Finding null string

P: n/a
How do you find if the returned XML string does not contain any
record/elements?

The XML string i receive just has the structure if there are not records,
How do I check for this?

<?xml version="1.0" encoding="UTF-8"?>
<array-list xsi:type="java:java.util.ArrayList"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>

Thanks
Nov 16 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

"GeRmIc" <Ge****@discussions.microsoft.com> wrote in message
news:25**********************************@microsof t.com...
How do you find if the returned XML string does not contain any
record/elements?

The XML string i receive just has the structure if there are not records,
How do I check for this?

<?xml version="1.0" encoding="UTF-8"?>
<array-list xsi:type="java:java.util.ArrayList"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>


Well, the most basic way would be to load it into an XmlReader and read
until the end, setting a flag if an element is reached.

How are you parsing your XML if there *are* elements?

Nov 16 '05 #2

P: n/a
Hi,

Right now i am passing the XML to a dataset and then doing a foreach loop on
it and getting the necessary elements.

Ex:
String str;
str = mywebservice(x,....);
XmlTextReader reader = new XmlTextReader(str);
DataSet ds = new DataSet();
ds.ReadXml(reader);

foreach(DataRow dr in ds.Tables[0].Rows)
{
x = dr["NID"] etc.,
}
Nov 16 '05 #3

P: n/a

"GeRmIc" <Ge****@discussions.microsoft.com> wrote in message
news:8E**********************************@microsof t.com...
Hi,

Right now i am passing the XML to a dataset and then doing a foreach loop
on
it and getting the necessary elements.

Ex:
String str;
str = mywebservice(x,....);
XmlTextReader reader = new XmlTextReader(str);
DataSet ds = new DataSet();
ds.ReadXml(reader);

foreach(DataRow dr in ds.Tables[0].Rows)
{
x = dr["NID"] etc.,
}


Well, can't you check the row count to determine if they are empty and
generate empty strings that way?
Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.