Remove xsi nil through regex

DaNaJOnAs

New Member
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. \[code\].*xsi\:nil\=\"true\" \/\>\[/code\]The above regex match works perfect for the below input\[code\]<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>\[/code\]But not for this input\[code\]<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>\[/code\]Desired output is\[code\]<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>\[/code\]Update:The property name and the level is only known at run time. Please refer a different xml below\[code\]<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>\[/code\]The desired output for the above xml is \[code\]<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>\[/code\]Could someone please help me Thanks,Esen
 
Back
Top