Community discussion forum

Avoid xml element if value is null

  • 7 months ago

    Hi,

    I am writing xml file from sql server database(Stored Proc) using Xml text writer class ,i

    My query is ,If database  datacolumn value has" null" then ,i dont want to show null element in xml file

    means i dont need particular end element in xml file

     

    example:

    1.<ID>1908</ID>
      <LOCALID>0123456789</LOCALID>
      <Sname>1660</Sname>
      <State>NJ</State>
      <Zip>30824</Zip> 

    If State value is null

    2.<ID>1908</ID>
      <LOCALID>0123456789</LOCALID>
      <Sname>1660</Sname>
        <Zip>30824</Zip>

    I wanted out put like 2 xml file.Please suggest this is very urgent to me.

    Thanks in advance!!!.

  • Advertisement

    Simply the fastest line-level profiler for .NET ever

    “The low overhead means it has minimal impact on the execution of my program”
    Mark Everest, Development Team Leader, Renault F1 Team Ltd.

    Try out the new ANTS Profiler 4 for yourself. Download your 14-day trial now

  • 7 months ago

    I came here looking for some help with Xml, although I don't think that's going to happen any time soon.

    Have you tried typing your output out using a schema, because you can then set a default value. The only problem here is, your xml output must be very strict and follow the schema or everything will fail.

Post a reply

Enter your message below

Sign in or Join us (it's free).