I got a code that looks like this.
Delete public zeroes (feed items) {XmlDocument Document = New XmlDocument (); Doc.Load ("Feed.xml"); XmlNodeList nodes = doc.SelectNodes ("/ Feed / Input"); Forwarding (XMLNode Node in nodes) {if (nodon.selectinglingnode ("id") .Intertext == item.ed.toString ()) {nodes [iterator]. Remove all (); Noden.RemoveAll (); break; }} Doctor.Service ("Feed.xml"); }
This is an example of my xml
& lt ;? Xml version = "1.0" encoding = "UTF-8" standalone = "yes"? & Gt; & Lt; Feed & gt; & Lt; Input & gt; & Lt; Name & gt; Examplename & lt; / Name & gt; & Lt; Eid & gt; 572b9c08-0d76-415d-9b53-ac2e87fceae6 & lt; / Id & gt; & Lt; URL & gt; Examppleurl & lt; / URL & gt; & Lt; Category & gt; Logic.Entities.Category & lt; / Category & gt; & Lt; Feed & gt; & Lt; Eid & gt; ExampleID & lt; / Id & gt; & Lt; Title & gt; 12. A strange week Swedish and lieutenant; / Heading & gt; & Lt; Attachments & gt; Example.mp3 & lt; / Attachment & gt; & Lt; / Feed & gt; & Lt; Feed & gt; & Lt; Eid & gt; Anotherexampleid & lt; / Id & gt; & Lt; Title & gt; 11. Non-Malala-boy & lt; / Heading & gt; & Lt; Attachments & gt; another example. MP3 & lt; / Attachment & gt; & Lt; / Feed & gt; & Lt; / Input & gt; & Lt; Input & gt; & Lt; Feed & gt; & Lt; Input & gt; & Lt; Name & gt; Examplename & lt; / Name & gt; & Lt; Eid & gt; 572b9c08-0d76-415d-9b53-ac2e87fceae6 & lt; / Id & gt; & Lt; URL & gt; Examppleurl & lt; / URL & gt; & Lt; Category & gt; Logic.Entities.Category & lt; / Category & gt; & Lt; Feed & gt; & Lt; Eid & gt; ExampleID & lt; / Id & gt; & Lt; Title & gt; 12. A strange week Swedish and lieutenant; / Heading & gt; & Lt; Attachments & gt; Example.mp3 & lt; / Attachment & gt; & Lt; / Feed & gt; & Lt; Feed & gt; & Lt; Eid & gt; Anotherexampleid & lt; / Id & gt; & Lt; Title & gt; 11. Non-Malala-boy & lt; / Heading & gt; & Lt; Attachments & gt; another example. MP3 & lt; / Attachment & gt; & Lt; / Feed & gt; & Lt; / Input & gt; & Lt; / Input & gt; & Lt; / Feed & gt;
When I extract it like a code given above, I want to remove one, but leaves empty
& lt ; Input & gt; & Lt; / Input & gt;
So my problem is that I want to remove empty inputs ... will I move forward with it?
Thank you.
You can only remove and then delete them like this: & lt; Input & gt; Can select node:
string xpath = String.Format ("/ feeds / input [id = '{0}']", item id. ToString ( )); XmlNodeList nodes = Doctor. Selection node (xpath);
foreach (XMLNode node in nodes) {noden.ParentNode.RemoveChild (noden); }
Comments
Post a Comment