CopyPastor

Detecting plagiarism made easy.

Score: 1; Reported for: Exact paragraph match Open both answers

Possible Plagiarism

Reposted on 2019-10-13
by jdweng

Original Post

Original - Posted on 2019-09-21
by jdweng



            
Present in both answers; Present only in the new answer; Present only in the old answer;

Simple with xml linq
<!-- begin snippet: js hide: false console: true babel: false -->
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Xml; using System.Xml.Linq; using System.IO;
namespace ConsoleApplication1 { class Program { const string FILENAME = @"c:\temp\test.xml"; static void Main(string[] args) { string input = File.ReadAllText(FILENAME); XDocument doc = XDocument.Parse(input);
string[] data = doc.Descendants("items").Select(x => (string)x).ToArray();
string splitData = string.Join(" / ", data.Select((x, i) => new { data = x, index = i }).GroupBy(x => x.index / 2).Select(x => string.Join(" , ", x.Select(y => y.data))));
XElement newDoc = new XElement("root", new XElement("table", new XElement("items", splitData))); } } }

<!-- end snippet -->

Using Xml Linq :
<!-- begin snippet: js hide: false console: true babel: false -->
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Xml; using System.Xml.Linq;
namespace ConsoleApplication1 { class Program { const string FILENAME = @"c:\temp\test.xml"; static void Main(string[] args) { XDocument doc = XDocument.Load(FILENAME); XElement root = doc.Root;
List<XElement> children = root.Elements().ToList(); string[] items = root.Descendants("items").Select(x => (string)x).ToArray();
for (int i = 0; i < children.Count; i++) { if (i == 0) { children[i].Element("items").ReplaceWith(new XElement("items", string.Join(",", items))); } else { children[i].Remove(); } } } } }

<!-- end snippet -->


        
Present in both answers; Present only in the new answer; Present only in the old answer;