Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8007835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:57:16+00:00 2026-06-04T17:57:16+00:00

I have a third party component that produce serialized xml and stored procedure that

  • 0

I have a third party component that produce serialized xml and stored procedure that parse xml and insert values into tables.

I am having trouble with xsi nil handled in the component and sql stored procedure. I don’t have control to change either the component or the stored procedure. So the IsNullable attribute on the property solution and not xsi=true on the procedure solution doesn’t help me.

I am trying to handle this using regex.

.*xsi\:nil\=\"true\" \/\>

The above regex match works perfect for the below input

<Root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<prop1>
    <prop11>abc</prop11>
    <prop12 xsi:nil="true" />
    <prop13>def</prop13>
</prop1>
</Root>

But not for this input

<Root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><prop1><prop11>abc</prop11><prop12 xsi:nil="true" /><prop13>def</prop13></prop1></Root>

Desired output is

<Root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<prop1>
    <prop11>abc</prop11>
    <prop13>def</prop13>
</prop1>
</Root>

Update:
The property name and the level is only known at run time. Please refer a different xml below

<Root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<pa>
    <paa>abc</paa>
    <pab xsi:nil="true" />
    <pac>def</pac>
            <pad>
               <pada>val1</pada>
               <padb xsi:nil="true" />
               <padc>
                     <padca>vala</padca>
                     <padcb xsi:nil="true" />
               </padc>
            <pad>
</prop1>
</Root>

The desired output for the above xml is

<Root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<pa>
    <paa>abc</paa>
    <pac>def</pac>
            <pad>
               <pada>val1</pada>
               <padc>
                     <padca>vala</padca>
               </padc>
            <pad>
</prop1>
</Root>

Could someone please help me

Thanks,

Esen

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T17:57:17+00:00Added an answer on June 4, 2026 at 5:57 pm

    Using the XPath from this library: https://github.com/ChuckSavage/XmlLib/

    I get the XElements that have xsi:nil=true with:

    XElement root = XElement.Load(file);
    // or root = XElement.Parse(xml);
    IEnumerable<XElement> result = root.XPath("//*[@xsi:nil={0}]", true);
    result.ToList().ForEach(x => x.Remove());
    root.Save(file);
    // or xml = root.ToString();
    

    I tested it with this XML:

    <Root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <prop1>
        <prop10 xsi:nil="true" />
        <prop11>abc</prop11>
        <prop12 xsi:nil="true" />
        <prop13>def</prop13>
        <prop14 xsi:nil="true" />
        <prop15>def</prop15>
        <prop16 xsi:nil="true" />
      </prop1>
    </Root>
    

    And found all 4 XElements. From there they are removed.

    The resulting XML is:

    <Root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <prop1>
        <prop11>abc</prop11>
        <prop13>def</prop13>
        <prop15>def</prop15>
      </prop1>
    </Root>
    

    If you don’t care that the xsi:nil is true, and you just want all nodes with the xsi:nil attribute removed, you can frame the XPath like:

    IEnumerable<XElement> result = root.XPath("//*[@xsi:nil]");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a third party web service that returns this xml <book> <release_date>0000-00-00</release_date> </book>
I have a third party COM component (they don't offer a .Net assy), that
IE7/Windows XP I have a third party component in my page that does a
We have old .net 1.1 project that is using a third party component. Aparently
I frequently have svn-based projects that include third-party components such as the TinyMCE (in-browser
I have a third party component I'm using and I'm seeing some issues with
I have a third party component written in C/C++ (on VS 2010) which can
I have third-party C code that writes data to a file. I want to
I have third party sites that link to some images on my site. The
I have a third-party library that is sometimes throwing an exception. So I decided

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.