How to delete specific node in omnixml delphi
Posted
by
Erwan
on Stack Overflow
See other posts from Stack Overflow
or by Erwan
Published on 2012-03-23T02:58:49Z
Indexed on
2012/03/24
11:29 UTC
Read the original article
Hit count: 618
i've read this answer but i don't know how to use that sample in my case. I have an xml file
<Archive>
<Source>
<Name>321</Name>
<BatchID>123</BatchID>
</Source>
<DataList>
<Data>
<PN>AAAA</PN>
<FN>1111</FN>
</Data>
<Data>
<PN>BBBB</PN>
<FN>2222</FN>
</Data>
</DataList>
</Archive>
How can i delete the Node that has PN=BBBB?
I'm so sorry, i think i'm not clear in my question, my bad, My Question is how to delete this section:
<Data>
<PN>BBBB</PN>
<FN>2222</FN>
</Data>
not only this section
<PN>BBBB</PN>
The Answer: Thanks to Runner, i modified a little bit of his code
DeleteNode := XMLDoc.DocumentElement.SelectSingleNode('/Archive/DataList/Data[PN="BBBB"]');
DeleteNode.ParentNode.RemoveChild(DeleteNode);
© Stack Overflow or respective owner