Null nodes in xml

Posts   
 
    
danny
User
Posts: 2
Joined: 02-Feb-2005
# Posted on: 02-Feb-2005 13:49:15   

Hi,

I'm writing a webservice which returns an xml document to be used by flash to display the data. The problem I have is that if there are null values in the database then the nodes are omitted which causes a problem for flash because the nodes are referenced by index as opposed to the name of the node.

Are there any setting within llblgen which will can help me out or another approcah you can recommend, have attached sample code.

Am adding typed list datatable output to a dataset and then consuming with an xmldatadocument

Any help is much appreciated

Thanks in advance

CampaignSearchTypedList campaigns = new CampaignSearchTypedList(); IPredicateExpression filter = new PredicateExpression(); filter.Add(PredicateFactory.CompareValue(Adidas.Data.CampaignFieldIndex.Enabled, ComparisonOperator.Equal, 1));

//add order by ISortExpression sorter = new SortExpression(SortClauseFactory.Create(Adidas.Data.CampaignFieldIndex.Name, SortOperator.Ascending));

//fill dataset (No of Records, SortByClause, AllowDuplicates, Filter) campaigns.Fill(0, sorter, false, filter);

DataSet ds = new DataSet("Root"); ds.Tables.Add(campaigns); ds.EnforceConstraints = false;

XmlDataDocument campaignSearch = new XmlDataDocument(ds);

return campaignSearch;

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 02-Feb-2005 15:15:30   

The xml export routine should create a node for a field no matter what value. However if the value is null, there is no child node of the field node for the value, which is logical, it's not there (IMHO).

Do you experience just no field nodes at all when the field is null?

Frans Bouma | Lead developer LLBLGen Pro
danny
User
Posts: 2
Joined: 02-Feb-2005
# Posted on: 02-Feb-2005 16:39:30   

Thanks for the prompt reply.

That's correct it simply omits the node completely as opposed to adding an <empty /> node as I'd expect... I could loop through the datatable replacing nulls with empty strings etc but this seems like overkill....very frustrating

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 02-Feb-2005 17:17:43   

danny wrote:

Thanks for the prompt reply.

That's correct it simply omits the node completely as opposed to adding an <empty /> node as I'd expect... I could loop through the datatable replacing nulls with empty strings etc but this seems like overkill....very frustrating

ah, you're using teh Dataset's xml export facilities and then you'll get the null values... I was assuming you used WriteXml() on an entity collection.

You can add a DataColumn expression to campaigns.Columns[index].Expression in which you use ISNULL(columnname, '') Perhaps that helps you a bit.

Frans Bouma | Lead developer LLBLGen Pro