static void Main(string[] args) { XElement xelement = XElement.Load(@"C:\Users\Umar\Desktop\sample.xml"); IEnumerable <XElement> parseResult = xelement.Elements(); Crud_DatabaseEntities1 gyt = new Crud_DatabaseEntities1(); //Iterate and Save Into Database foreach (var item in parseResult) { System.Console.WriteLine("Item Id : {0} ,Item Name : {1}, Item Sex : {2}, Item Phone : {3}", item.Element("EmpId").Value, item.Element("Name").Value, item.Element("Sex").Value, item.Element("Phone").Value ); //Save Into Database var message = new XmlParsing { EmpId = Convert.ToInt64(item.Element("EmpId").Value), Name = item.Element("Name").Value, Sex = item.Element("Sex").Value, Phone = item.Element("Phone").Value }; gyt.XmlParsings.Add(message); gyt.SaveChanges(); } Console.ReadKey(); }
public void XmlParser_must_properly_parse_chunks_bigger_than_its_buffer_size() { var documentStream = Source .Single("<doc>") .Concat(Source.Single( @" <elem> <item>i1</item> <item>i2</item> <item>i3</item> <item>i1</item> <item>i2</item> <item>i3</item> <item>i1</item> <item>i2</item> <item>i3</item> <item>i1</item> <item>i2</item> <item>i3</item> </elem>" )) .Concat(Source.Single("</doc>")); var fut = documentStream .Select(ByteString.FromString) .Via(XmlParsing.Parser(bufferSize: 64)) .RunWith(Sink.Seq <IParseEvent>(), _materializer); fut.Invoking(f => f.Wait(TimeSpan.FromSeconds(3))).ShouldNotThrow(); }
public XmlProcessingTest(ITestOutputHelper output) : base(output: output) { _materializer = Sys.Materializer(); _parser = Flow.Create <string>() .Select(ByteString.FromString) .Via(XmlParsing.Parser()) .ToMaterialized(Sink.Seq <IParseEvent>(), Keep.Right); }
public XmlSubsliceTest(ITestOutputHelper output) : base(output: output) { _materializer = Sys.Materializer(); _parser = Flow.Create <string>() .Select(ByteString.FromString) .Via(XmlParsing.Parser()) .Via(XmlParsing.Subslice(new [] { "doc", "elem", "item" }.ToImmutableArray())) .ToMaterialized(Sink.Seq <IParseEvent>(), Keep.Right); }
public ProductDetailsViewModel(string spec) { xparse = new XmlParsing(spec); List <string> lista = new List <string>(xparse.ParseXml()); foreach (string item in lista) { ProdDetails += item + "\n"; } ProdDetails = ProdDetails.Remove(ProdDetails.Count() - 2); ExecuteBack = new CommandHandler(ExeBack, () => true); }
public void XmlParser_must_properly_parse_large_XML() { var elements = Enumerable.Range(0, 10).Select(i => i.ToString()).ToImmutableArray(); var documentStream = Source .Single("<doc>") .Concat(Source.FromEnumerator(elements.Select(s => $"<elem>{s}</elem>").GetEnumerator)) .Concat(Source.Single("</doc>")); var fut = documentStream .Select(ByteString.FromString) .Via(XmlParsing.Parser()) .Collect(evt => evt is Characters ? evt : null) .Collect(evt => ((Characters)evt).Text) .RunWith(Sink.Seq <string>(), _materializer); fut.Wait(TimeSpan.FromSeconds(3)); fut.Result.ShouldAllBeEquivalentTo(elements); }
public static void startBuildProcess(string buildRequest) // Initiating the thread process { XmlParsing xml = new XmlParsing(); xml.XMLLoad("../../../RepositoryStorage/" + buildRequest); Author = xml.Parse("author"); DateTime = xml.Parse("dateTime"); Tested = xml.ParseList("tested"); String testDriver = xml.Parse("testDriver"); Tested.Add(testDriver); CommMessage requestFiles = new CommMessage(CommMessage.MessageType.request); requestFiles.author = "ChildBuilder"; requestFiles.command = "RequestParsedFiles"; requestFiles.fileName = FolderPath + "/"; requestFiles.from = "http://localhost:" + PortChildBuilder.ToString() + "/IMessagePassingComm"; requestFiles.to = "http://localhost:8081/IMessagePassingComm"; requestFiles.arguments = Tested; childbuilder.postMessage(requestFiles); }
/*-----------------------------<this it parse test request>---------------------------*/ private void ParseTestRequest(string path) { XmlParsing xml = new XmlParsing(); xml.LoadXml(path); Author = xml.Parse("author"); _DateTime = xml.Parse("dateTime"); String testDriver = xml.Parse("testDriver"); CommMessage requestFiles = new CommMessage(CommMessage.MessageType.request); requestFiles.from = from; requestFiles.to = toAddress; requestFiles.command = "SendDllFiles"; requestFiles.xmlString = testDriver; requestFiles.fileName = TestFolderPath; requestFiles.author = "TestHarness"; testHarness.postMessage(requestFiles); Thread.Sleep(10000); Console.WriteLine(" \n Requirement 9:The Test Harness shall attempt to load each test library it receives and execute it. It shall submit the results of testing to the Repository."); Console.WriteLine("===================================================================================================================================================================== "); Console.Write("\n \n"); TestProcess(testDriver); }