linq to xml how to move one element from one xml to another -
I am facing a problem, I have two XML files.
Plugins.xml
& lt; SolutionProfile xmlns = "http://schemas.microsoft.com/pag/cab-profile" & gt; & Lt; Module & gt; & Lt; ModuleInfo AssemblyFile = "PluginXXX.dll" /> & Lt; / Module & gt; & Lt; / SolutionProfile & gt;
.xml of profiles
& lt; SolutionProfile xmlns = "http://schemas.microsoft.com/pag/cab-profile/0.0" & gt; & Lt; Section name = "Services" & gt; & Lt; Module & gt; & Lt; ModuleInfo AssemblyFile = "Module.dll" /> & Lt; / Module & gt; & Lt; / Section & gt; & Lt; Section name = "apps" & gt; & Lt; Dependency & gt; & Lt; Dependency name = "Services" /> & Lt; / Dependencies & gt; & Lt; Module & gt; & Lt; ModuleInfo AssemblyFile = "PluginABC.dll" & gt; & Lt; / Module & gt; & Lt; / Section & gt; & Lt; / SolutionProfile & gt;
I want to take PluginsXXX.dll from Plugins.xml to Profile Catalog.xml.
The code used by me as a
public static zero plugin is loaded (string plugin name) {XmlWriterSettings Settings = New XmlWriterSettings (); Settings.OmitXmlDeclaration = True; Settings.Indent = true; XDocument pluginDoc = XDocument.Load ("Plugins.xml"); XDocument ProfilesList.doc = XDocument.Load ("ProfileCatalog.xml"); XmlWriter PluginDocumentalter = XmlWriter.Create ("Plugins.xml", Settings); XmlWriter ProfileCell Disclaimer XML =. XmlWriter.Create ("ProfileCatalog.xml", settings); XNamespace ns = "http://schemas.microsoft.com/pag/cab-profile"; Var res = pluginDoc.Descendants (ns + "ModuleInfo") where plugin from plugin Attribute ("assembly file"). Value == plugin plugin; // Save the plugin to remove XElement pluginToMove = res.FirstOrDefault (); Remove from // xml res.FirstOrDefault () Remove (); // save xml back plugin dock Save (pluginDocXmlWriter); XNamespace pns = "http://schemas.microsoft.com/pag/cab-profile/2.0"; Var pRes = (Select PC from PC Plugin from CatalogDoc.Descendants (PNS + "module") PCPlugin). Skip (1). Take (1)). FirstOrDefault (); PRes.Add (pluginToMove); ProfileCatalogDoc.Save (profileCatalogDocxmlWriter); // TODO: Plugins name for the profiles from plugins.xml ProfileCatalog.xml Profile CatalogDocxmlWriter.Close (); PluginDocXmlWriter.Close (); }
Note is the XMLN difference between the two files when I transfer the Plugins.xml from Plugins.xml then adds this element to ProfileCatalog.xml
& lt; ModuleInfo AssemblyFile = "PluginXXX.dll" xmlns = "http://schemas.microsoft.com/pag/cab-profile" />
I want to delete this xmlns before adding this file.
Please give me a solution.
i replace = "post-text" itemprop = "text">
Solution
pRes.Add (PluginToov);
value)));
Comments
Post a Comment