public static XmlDocument TransformIncludes(this XmlDocument dom) { foreach (XmlNode item in dom.DocumentElement.SelectNodes("include")) { var d = new XmlDocument(); d.Load(item.Attributes?["src"]?.Value); switch (item.Attributes?["type"]?.Value) { case "text/xml": var n = dom.ImportNode(d.DocumentElement, true); dom.DocumentElement.ReplaceChild(n, item); break; case "text/component+xml": dom.CreateComponent(d.ToString()); dom.DocumentElement.RemoveChild(item); break; default: dom.CreateComponent(d.ToString()); dom.DocumentElement.RemoveChild(item); break; } } return(dom); }
public async Task SetData(string key, string value) { Console.WriteLine(">>> Android: SetData, key = " + key + ", value = " + value); // Search the tree for the key - if it's not there, add it. // If it's there, then update the InnerText. Boolean keyFound = false; try { await LoadXmlFileAsync("LocalDataForXam_file.xml"); // sets xmlLocalData Console.WriteLine(">>> xmlLocalData = " + xmlLocalData.ToString()); for (int n = 0; n < xmlLocalData.FirstChild.ChildNodes.Count; n++) { if (key == xmlLocalData.FirstChild.ChildNodes[n].Name) { // found, update the value in the tree keyFound = true; xmlLocalData.FirstChild.ChildNodes[n].InnerText = value; break; } } // Create a new node. if (keyFound == false) { XmlNode newNode = xmlLocalData.CreateNode(XmlNodeType.Element, key, null); newNode.InnerText = value; // Add the node to the XML tree xmlLocalData.DocumentElement.AppendChild(newNode); } var docsPath = Android.OS.Environment.ExternalStorageDirectory.Path + @"/LocalDataForXam"; // create it if it doesn't exist System.IO.Directory.CreateDirectory(docsPath); string completeDocsPath = Path.Combine(docsPath, "LocalDataForXam_file.xml"); Console.WriteLine(">>> completeDocsPath = " + completeDocsPath); xmlLocalData.Save(completeDocsPath); } catch (Exception ex) { Console.WriteLine(">>> Exception: " + ex.StackTrace + ex.Message); } }
/// <summary> /// Menu item edit variable clicked. /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">E.</param> void EditVariable_Clicked(object sender, EventArgs e) { // Active parser item if (ActiveParserItem == null) { return; } Dialog _edit; if (ActiveParserItem.value is List <ParserItem> ) { _edit = new EditArrayVariable(ActiveParserItem, ActiveRequest); } else { _edit = new EditResponseVariable(ActiveParserItem, ActiveRequest); } var d = _edit.Run(); if (d == Command.Ok) { if (_edit is EditArrayVariable) { ActiveParserItem.value = ((EditArrayVariable)_edit).GetValue(); } else { ActiveParserItem.value = ((EditResponseVariable)_edit).GetValue(); } // Create string string template = Parser.serialize(Template); if (ActiveRequest.ResponseTemplateType == ContentType.XML) { XmlDocument doc = JsonConvert.DeserializeXmlNode(template); Console.WriteLine(doc.ToString()); ActiveRequest.ResponseTemplate = doc.ToString(); } else { ActiveRequest.ResponseTemplate = template; } // Test RefreshContent(); } _edit.Dispose(); }
public string RebuildContent() { try { string strReturn = string.Empty; //Declaration strReturn += _Declaration.ToString(); //DocType strReturn += _DocType.ToString(); //Entity foreach (XmlEntity item in _XmlEntity) { strReturn += item.ToString(); } //Notation //Node Content strReturn += _XmlDocument.ToString(); return(strReturn); } catch (Exception ex) { throw ex; } }
public void TransformProcessingInstructions2() { // Arrange var document = new XmlDocument(@"<Wix xmlns=""http://schemas.microsoft.com/wix/2006/wi""> <?define ProductName=""My product for ArcGIS 10.2"" x=""2""?> <?define ProductVersion=""1.3.0.0"" ?> </Wix>"); document.ReplaceKey(new[] { "Wix", "Nested", "Nested2", "?define", "@ProductName" }, "My product for ArcGIS 10.3"); document.RemoveKey(new[] { "Wix", "?define[@ProductName = 'My product for ArcGIS 10.2']", "@x" }); document.RemoveKey(new[] { "Wix", "?define[@ProductVersion = '1.3.0.0']" }); var result = document.ToString(); // Assert Assert.Equal(@"<Wix xmlns=""http://schemas.microsoft.com/wix/2006/wi""> <Nested> <Nested2> <?define ProductName=""My product for ArcGIS 10.3""?> </Nested2> </Nested> <?define ProductName=""My product for ArcGIS 10.2""?> </Wix>", result, ignoreCase: true, ignoreLineEndingDifferences: true, ignoreWhiteSpaceDifferences: true); }
public void TransformWithColonInAttributeName() { // Arrange var document = new XmlDocument(@"<?xml version=""1.0"" encoding=""utf-8""?> <configuration> <appSettings> <add key=""Auth:Environment"" value=""Testing"" /> <add key=""Auth:Credential"" value=""abcefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"" /> <add key=""Auth:Type"" value=""Basic"" /> <add key=""Auth:Provider:Name"" value=""Name"" /> </appSettings> </configuration>"); document.ReplaceKey(new[] { "configuration", "appSettings", "add[@key = 'Auth:Environment']", "@value" }, "Production"); document.ReplaceKey(new[] { "configuration", "appSettings", "add[@key=\"Auth:Credential\"]", "@value" }, "XqoL6MXqOPeGTxXrJsQA7gK5cXLvnlSYJUtAwFWbRo7GDkbsSu"); document.ReplaceKey(new[] { "configuration", "appSettings", "add[@key=\"Auth:Type\"]", "@value" }, "Bearer"); document.ReplaceKey(new[] { "configuration", "appSettings", "add[@key=\"Auth:Provider:Name\"]", "@value" }, "ABC"); var result = document.ToString(); // Assert Assert.Equal(@"<?xml version=""1.0"" encoding=""utf-8""?> <configuration> <appSettings> <add key=""Auth:Environment"" value=""Production"" /> <add key=""Auth:Credential"" value=""XqoL6MXqOPeGTxXrJsQA7gK5cXLvnlSYJUtAwFWbRo7GDkbsSu"" /> <add key=""Auth:Type"" value=""Bearer"" /> <add key=""Auth:Provider:Name"" value=""ABC"" /> </appSettings> </configuration>", result, ignoreCase: true, ignoreLineEndingDifferences: true, ignoreWhiteSpaceDifferences: true); }
public void TransformWithNamesapce5() { // Arrange var document = new XmlDocument(@"<?xml version=""1.0"" encoding=""utf-8""?> <configuration> <appSettings> <add key=""ida:issuer"" value=""10000"" /> </appSettings> </configuration> "); // Act document.ReplaceKey(new[] { "configuration", "appSettings", "add[@key='ida:issuer']", "@value" }, "10001"); var result = document.ToString(); // Assert Assert.Equal(@"<?xml version=""1.0"" encoding=""utf-8""?> <configuration> <appSettings> <add key=""ida:issuer"" value=""10001"" /> </appSettings> </configuration>", result, ignoreCase: true, ignoreLineEndingDifferences: true, ignoreWhiteSpaceDifferences: true); }
public string GeneratePrettyXml(SqlCommunicatorConnection connection) { XmlDocument xDoc = new XmlDocument(); // Set our output settings: XmlWriterSettings xmlSettings = new XmlWriterSettings(); xmlSettings.OmitXmlDeclaration = false; xmlSettings.Indent = true; xmlSettings.NewLineOnAttributes = true; if (connection != null) { XPathNavigator xNav = xDoc.CreateNavigator(); // Generate our Xml Document: using (XmlWriter xw = xNav.AppendChild()) { XmlSerializer xs = new XmlSerializer(connection.GetType()); xs.Serialize(xw, connection); } } return(xDoc.ToString()); }
private void SaveLevelData(LevelObject[] prefabs, string TextContent, bool encriptar) { XmlDocument doc = new XmlDocument(); doc.LoadXml(TextContent); // Locate the level if exists, then remove it so we can recreate it XmlElement node = (XmlElement)doc.SelectSingleNode("//level[@name='" + levelName + "']"); if (node != null) { node.ParentNode.RemoveChild(node); } var xml = GetPrefabsXML(prefabs); XmlDocumentFragment xfrag = doc.CreateDocumentFragment(); xfrag.InnerXml = @xml.ToString(); doc.DocumentElement.AppendChild(xfrag); string filepath = Application.dataPath + @"/UI/LevelPacks/Resources/" + packName + ".xml"; string xmlSalvar = doc.ToString(); if (encriptar) { xmlSalvar = DataManager.Encrypt(xmlSalvar); } File.WriteAllText(filepath, xmlSalvar); doc.Save(filepath); }
public void XmlDownloadTest() { UTF8Encoding encoding = new UTF8Encoding(); byte[] contentAsBytes = encoding.GetBytes(TestResources.CharacterSheet); MemoryStream sourceResponseStream = new MemoryStream(); sourceResponseStream.Write(contentAsBytes, 0, contentAsBytes.Length); sourceResponseStream.Position = 0; XmlDocument contentAsXml = new XmlDocument(); contentAsXml.Load(new StringReader(TestResources.CharacterSheet)); Mock <HttpWebRequest> mockRequest = MockManager.Mock <HttpWebRequest>(Constructor.NotMocked); MockObject <HttpWebResponse> mockResponse = MockManager.MockObject <HttpWebResponse>(Constructor.Mocked); mockResponse.ExpectAndReturn("GetResponseStream", sourceResponseStream); mockRequest.ExpectAndReturn("GetResponse", mockResponse.Object); HttpWebService service = new HttpWebService(); XmlDocument result = service.DownloadXml("http://www.battleclinic.com"); StringAssert.AreEqualIgnoringCase(contentAsXml.ToString(), result.ToString()); sourceResponseStream.Close(); }
public void ReadFromXml(string XML) { XmlDocument xd = new XmlDocument(); xd.LoadXml(XML); xd.ToString(); }
public IHttpActionResult TestResukt(SOAPEnvelope sop) { //string xmlData = HttpContext.Current.Server.MapPath(@"D:/objectXmlWebApi.xml"); //XDocument Rsp = XDocument.Load(@"D:/objectXmlWebApi.xml"); XmlDocument doc = new XmlDocument(); doc.Load(@"D:\StepList.xml"); //TextReader testData = new StringReader(@"D:\soapenvelopefortest.xml"); //string testData = @"<StepList> // <Step> // <Name>My Name Is Isit</Name> // <Desc>Desc1</Desc> // </Step> // <Step> // <Name>Name2</Name> // <Desc>Desc2</Desc> // </Step> // </StepList>"; XmlSerializer serializer = new XmlSerializer(typeof(StepList)); using (TextReader reader = new StringReader(doc.ToString())) { StepList result = (StepList)serializer.Deserialize(reader); return(Ok(result)); } }
internal static string ToPrintableXml(this XmlDocument document) { using (var stream = new MemoryStream()) { using (var writer = XmlWriter.Create(stream, new XmlWriterSettings() { Encoding = Encoding.Unicode, Indent = true })) { try { document.WriteContentTo(writer); writer.Flush(); stream.Flush(); // Have to rewind the MemoryStream in order to read // its contents. stream.Position = 0; // Read MemoryStream contents into a StreamReader. var reader = new StreamReader(stream); // Extract the text from the StreamReader. return(reader.ReadToEnd()); } catch (Exception) { return(document.ToString()); } } } }
static void Main(string[] args) { // The code provided will print ‘Hello World’ to the console. // Press Ctrl+F5 (or go to Debug > Start Without Debugging) to run your app. DocumentDirector dir = new DocumentDirector(); JsonDocBuilder builder = new JsonDocBuilder(); dir.ConstructDocumento(1, builder); string json = builder.GetResult().ToString(); Console.WriteLine(json); XmlDocBuilder xmlBuilder = new XmlDocBuilder(); dir.ConstructDocumento(1, xmlBuilder); XmlDocument xml = xmlBuilder.GetResult(); Console.WriteLine(xml.ToString()); FluentJsonDocBuilder fluent = new FluentJsonDocBuilder(); dir.ConstructDocumento(1, fluent); json = fluent.GetResult().ToString(); Console.WriteLine(json); }
public static IActionResult Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req, TraceWriter log) { log.Info("C# HTTP trigger function processed a request."); string name = req.Query["name"]; string json = @"{ '@Id': 1, 'Email': '*****@*****.**', 'Active': true, 'CreatedDate': '2013-01-20T00:00:00Z', 'Roles': [ 'User', 'Admin' ], 'Team': { '@Id': 2, 'Name': 'Software Developers', 'Description': 'Creators of fine software products and services.' } }"; XmlDocument doc = JsonConvert.DeserializeXmlNode(json, "root"); log.Info("C# " + doc.ToString()); return(name != null ? (ActionResult) new OkObjectResult($"Hello, {doc.OuterXml}") : new BadRequestObjectResult("Please pass a name on the query string or in the request body")); }
public void XmlAsyncDownloadTest() { UTF8Encoding encoding = new UTF8Encoding(); byte[] contentAsBytes = encoding.GetBytes(TestResources.CharacterSheet); MemoryStream sourceResponseStream = new MemoryStream(); sourceResponseStream.Write(contentAsBytes, 0, contentAsBytes.Length); sourceResponseStream.Position = 0; XmlDocument contentAsXml = new XmlDocument(); contentAsXml.Load(new StringReader(TestResources.CharacterSheet)); Mock <HttpWebRequest> mockRequest = MockManager.Mock <HttpWebRequest>(Constructor.NotMocked); MockObject <HttpWebResponse> mockResponse = MockManager.MockObject <HttpWebResponse>(Constructor.Mocked); mockResponse.ExpectAndReturn("GetResponseStream", sourceResponseStream); mockRequest.ExpectAndReturn("GetResponse", mockResponse.Object); _xmlAsyncCompletedTrigger = new AutoResetEvent(false); HttpWebService service = new HttpWebService(); service.DownloadXmlAsync("http://www.battleclinic.com", null, XmlAysncDownloadTestCompleted, null); _xmlAsyncCompletedTrigger.WaitOne(); if (_xmlAsyncDownloadResult.Error != null) { Assert.Fail(_xmlAsyncDownloadResult.Error.Message); } StringAssert.AreEqualIgnoringCase(contentAsXml.ToString(), _xmlAsyncDownloadResult.Result.ToString()); sourceResponseStream.Close(); _xmlAsyncCompletedTrigger = null; _xmlAsyncDownloadResult = null; }
public static void ValidateXml(XmlReader pXmlReader, string pXsdFilename) { if (pXmlReader == null || String.IsNullOrWhiteSpace(pXsdFilename)) { throw new ArgumentException(); } XmlReader xmlReader; XmlDocument xmlDocument = new XmlDocument(); using (pXmlReader) { xmlDocument.Load(pXmlReader); } XmlSchemaSet xmlSchemas = new XmlSchemaSet(); using (xmlReader = XmlReader.Create(pXsdFilename)) { xmlSchemas.Add("", xmlReader); } Debug.WriteLine(xmlDocument.ToString()); Debug.WriteLine("================="); Debug.WriteLine(xmlSchemas.ToString()); xmlDocument.Schemas = xmlSchemas; xmlDocument.Validate( (o, e) => { throw e.Exception; }); }
public bool initConfig() { string functionName = "initConfig"; bool returnValue = false; dataSet = new DataSet(); xmlDocument = new XmlDocument(); Log.WriteLog(LogLevel.TRACE, programName, functionName, "process"); try { if (!File.Exists(configFile)) { Log.WriteLog(LogLevel.INFO, programName, functionName, "configFile Not Exists"); makeXML(); } dataSet.ReadXml(configFile); xmlDocument.LoadXml(dataSet.GetXml()); Log.WriteLog(LogLevel.DEBUG, programName, functionName, "XML Data", xmlDocument.ToString()); returnValue = propertysLoad(); } catch (System.Exception ex) { Log.WriteLog(LogLevel.ERROR, programName, functionName, "Exception", ex.ToString()); returnValue = false; } return(returnValue); }
public void Remove() { // Arrange var document = new XmlDocument(@"<xml> <a> <x>1</x> </a> <b> <x>1</x> </b> <c key=""item1"" foo=""bar"">3</c> </xml>"); // Act document.RemoveKey(new[] { "xml", "a" }); document.RemoveKey(new[] { "xml", "b", "x" }); document.RemoveKey(new[] { "xml", "c", "@key" }); var result = document.ToString(); // Assert Assert.Equal(@"<xml> <b /> <c foo=""bar"">3</c> </xml>", result, ignoreCase: true, ignoreLineEndingDifferences: true, ignoreWhiteSpaceDifferences: true); }
/// <summary> /// Gets the <see cref="StudyStorageLocation"/> for the study associated with the specified <see cref="WorkQueue"/> item. /// </summary> /// <param name="item"></param> /// <returns></returns> static public String GetLoadDuplicateStorageLocation(WorkQueue item) { XmlDocument document = item.Data; return(document.ToString()); }
public void TransformWithNamesapce3() { // Arrange var document = new XmlDocument(@"<nlog xmlns=""http://www.nlog-project.org/schemas/NLog.xsd"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""> <targets> <target name=""file"" xsi:type=""File"" xsi:type2=""12345"" /> <xsi:element></xsi:element> </targets> </nlog>"); // Act document.ReplaceKey(new[] { "nlog", "targets", "target[@name='file']", "@xsi:type2" }, "val1"); document.ReplaceKey(new[] { "nlog", "targets", "target[@xsi:type='File']" }, "val2"); document.ReplaceKey(new[] { "nlog", "targets", "xsi:element" }, "val3"); document.ReplaceKey(new[] { "nlog", "targets", "xsi:element", "@prop" }, "val4"); var result = document.ToString(); // Assert Assert.Equal(@"<nlog xmlns=""http://www.nlog-project.org/schemas/NLog.xsd"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""> <targets> <target name=""file"" xsi:type=""File"" xsi:type2=""val1"">val2</target> <xsi:element prop=""val4"">val3</xsi:element> </targets> </nlog>", result, ignoreCase: true, ignoreLineEndingDifferences: true, ignoreWhiteSpaceDifferences: true); }
public void TransformWithNamesapce4() { // Arrange var document = new XmlDocument(@"<manifest xmlns:android=""http://schemas.android.com/apk/res/android"" package=""com.myapp.name.here"" android:installLocation=""auto"" android:versionCode=""10000"" android:versionName=""1""> <uses-sdk android:minSdkVersion=""18"" android:targetSdkVersion=""23"" /> <uses-permission android:name=""android.permission.CHANGE_WIFI_STATE"" /> <uses-permission android:name=""android.permission.ACCESS_WIFI_STATE"" /> <application android:label=""Scan Plan 2 Test"" android:icon="""" android:theme="""" /> </manifest>"); // Act document.ReplaceKey(new[] { "manifest", "@android:versionCode" }, "10001"); var result = document.ToString(); // Assert Assert.Equal(@"<manifest xmlns:android=""http://schemas.android.com/apk/res/android"" package=""com.myapp.name.here"" android:installLocation=""auto"" android:versionCode=""10001"" android:versionName=""1""> <uses-sdk android:minSdkVersion=""18"" android:targetSdkVersion=""23"" /> <uses-permission android:name=""android.permission.CHANGE_WIFI_STATE"" /> <uses-permission android:name=""android.permission.ACCESS_WIFI_STATE"" /> <application android:label=""Scan Plan 2 Test"" android:icon="""" android:theme="""" /> </manifest>", result, ignoreCase: true, ignoreLineEndingDifferences: true, ignoreWhiteSpaceDifferences: true); }
public XmlDocument MakeRequest(string requestUrl) { try { // maker the request to an external server HttpWebRequest request = WebRequest.Create(requestUrl) as HttpWebRequest; HttpWebResponse response = request.GetResponse() as HttpWebResponse; //set teh request to an xml document XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(response.GetResponseStream()); // return the document return (xmlDoc); //Literal1.Text = xmlDoc.ToString(); //CreateLog.Log("ERROR", "XMLDoc" + "What I am" + xmlDoc.ToString()); Log("ERROR", xmlDoc.ToString()); //CreateLog.CreateLog.Log("ERROR", xmlDoc.ToString()); } catch (Exception e) { //return null if an error occurs (possibly due to a non existent awbnumber) Console.WriteLine(e.Message); Console.Read(); return null; } }
// Token: 0x06000006 RID: 6 RVA: 0x000020F8 File Offset: 0x000002F8 private static void ExtendedSceneLoadInUpdate() { try { Logger.Log(LogLevel.Info, "Start loading VMDPlay info from scene data."); object obj; if (ExtendedSave.GetSceneExtendedDataById("KKVMDPlayExtSave").data.TryGetValue("xml", out obj)) { if (obj != null && obj is byte[]) { Logger.Log(LogLevel.Info, string.Format("Found VMDPlay info XML data: {0}", ((byte[])obj).Length)); MemoryStream inStream = new MemoryStream((byte[])obj); Console.WriteLine("ExtSave: Loading from PNG."); XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(inStream); Console.WriteLine(xmlDocument.ToString()); KKVMDPlayExtSavePlugin.OnLoad(xmlDocument.DocumentElement); } else { Logger.Log(LogLevel.Message, "Data not found."); } } else { Logger.Log(LogLevel.Message, "Data not found."); } } catch (Exception ex) { Logger.Log(LogLevel.Error, string.Format("Failed to load data. {0}", ex.StackTrace)); } }
//starting a workflow sample public static void StartWorkflowSamples() { //you must open a K2 connection first. We will wrap the K2 connection into a using statement to ensure that it is closed using (Connection K2Conn = new Connection()) { K2Conn.Open("[servername]"); //first, create a new process instance. This only loads the process into memory, it does not start it yet. //Note: if the user does not have rights to start the workflow, an error will be thrown here ProcessInstance K2Proc = K2Conn.CreateProcessInstance(@"[ProjectName]\[Workflow Name]"); //specify the full name of the workflow //now that we have the process as an object in memory, we can set some properties before starting the process K2Proc.Folio = "[ProcessFolio]"; K2Proc.Priority = 1; //datafields should be accessed by name. Be aware of data types when setting values, and ensure that the data field names are spelled correctly! K2Proc.DataFields["[String DataField Name]"].Value = "[somevalue]"; K2Proc.DataFields["[Integer Datafield Name]"].Value = 1; K2Proc.DataFields["[Date Datafield Name]"].Value = DateTime.Now; //XML fields are set using an XML-formatted string XmlDocument xmlDoc = new XmlDocument(); //TODO: set up the XML document as required, or construct a valid XML string somehow K2Proc.XmlFields["[XML DataField Name]"].Value = xmlDoc.ToString(); //once you have set all the necessary values, start the process K2Conn.StartProcessInstance(K2Proc); //you can also start a process synchronously with the Sync override. This approach is used when you need to wait for the //first client event/wait-state in the workflow before returning the StartProcessInstance call, most commonly with //page-flow solutions or with automated testing code. This does take longer to return, so don't use it unless you have a specific reason to wait for the first wait-state or client event K2Conn.StartProcessInstance(K2Proc, true); } }
internal static string ToPrintableXml(this XmlDocument document) { using (var stream = new MemoryStream()) { using (var writer = new XmlTextWriter(stream, Encoding.Unicode)) { try { writer.Formatting = Formatting.Indented; document.WriteContentTo(writer); writer.Flush(); stream.Flush(); // Have to rewind the MemoryStream in order to read // its contents. stream.Position = 0; // Read MemoryStream contents into a StreamReader. var reader = new System.IO.StreamReader(stream); // Extract the text from the StreamReader. return(reader.ReadToEnd()); } catch (Exception) { return(document.ToString()); } } } }
public override string getCallbackResponse() { try { searchRequest.SelectSingleNode("/SearchOptions/OutputOptions/Offset").InnerText = "0"; searchRequest.SelectSingleNode("/SearchOptions/OutputOptions/Limit").InnerText = "500"; XmlDocument searchData = new Profiles.Search.Utilities.DataIO().Search(searchRequest, false, false); DebugLogging.Log("SeachCallbackResponse :" + searchRequest.ToString()); List <string> peopleURIs = new List <string>(); XmlNodeList people = searchData.GetElementsByTagName("rdf:object"); for (int i = 0; i < people.Count; i++) { peopleURIs.Add(people[i].Attributes["rdf:resource"].Value); } if (peopleURIs.Count > 0) { return(BuildJSONPersonIds(peopleURIs, "" + peopleURIs.Count + " people found")); } } catch (Exception e) { DebugLogging.Log(e.Message); } return(null); }
/// <summary> /// Gets this plan as an XML document. /// </summary> /// <returns></returns> public XmlDocument AsXml() { // return a copy so the caller can't modify ours var xml = new XmlDocument(); xml.LoadXml(_planXml.ToString()); return(xml); }
/// <summary> /// 获取收到的加密XML /// </summary> /// <param name="context"></param> private XmlDocument RequestXML(HttpContext context) { XmlDocument xmlDocEn = new XmlDocument(); xmlDocEn.Load(context.Request.InputStream);//加密的xml ToLog(xmlDocEn.ToString()); return(xmlDocEn); }
public void GetCamstarServicesForServer(string ServerName) { XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(_ServerListPath); XElement element = XElement.Parse(xmlDocument.ToString()); var result = element.Elements("Data").Elements("Server").Where(x => x.Name == ServerName); }
protected void Button1_Click(object sender, EventArgs e) { XmlDocument doc = new XmlDocument(); doc.Load(MapPath("ComicReviews.xml")); //XmlElement elem = doc.CreateElement("test"); //elem.InnerText = "it worked!"; //XmlNode oldCd; XmlElement root = doc.DocumentElement; //oldCd = root.SelectSingleNode("/catalog/cd[title='Hide your heart']"); XmlElement newCd = doc.CreateElement("ComicReview"); //newCd.SetAttribute("country", "Country.text"); newCd.InnerXml = "<ComicName>" + txtComicName.Text + "</ComicName> <ReviewerName>" + txtReviewer.Text + "</ReviewerName> <Rating>" + txtRating.Text + "</Rating> <Genre1>" + txtGenre1.Text + "</Genre1> <Genre2>" + txtGenre2.Text + "</Genre2> <Status>" + txtURL.Text + "</Status> <Quality>" + txtQuality.Text + "</Quality>"; //root.ReplaceChild(newCd, oldCd); root.PrependChild(newCd); Response.Write(doc.ToString()); doc.Save(MapPath("ComicReviews.xml")); }
public static List<ShortcutData> getShortcutData() { Debug.Log("Reading xml"); XmlDocument xml = new XmlDocument(); try{ xml.Load(configPath+shortcutConfig); } catch(Exception) { createConfig(); return getShortcutData(); } List<ShortcutData> data = new List<ShortcutData>(); ShortcutData d; Debug.Log(xml.ToString()); foreach(XmlNode n1 in xml.FirstChild.ChildNodes) { //Debug.Log(n1.Name+"/"+n1.InnerXml); d = new ShortcutData(); int x = -1; int y = -1; int wall = -1; foreach(XmlNode n2 in n1.ChildNodes) { switch(n2.Name) { case "name": d.name = n2.InnerText; break; case "path": d.path = n2.InnerText; break; case "icon": try { d.iconId = System.Convert.ToInt32(n2.InnerText); } catch(Exception) { d.loadIcon(n2.InnerText); n2.InnerText = d.iconId.ToString (); } break; case "model": //TODO break; case "model_enable": if(n2.InnerText == "true") d.modelEnabled = true; else d.modelEnabled = false; break; case "extension_standard": if(n2.InnerText == "true") d.modelEnabled = true; else d.extensionStandard = false; break; case "x": x = Convert.ToInt32(n2.InnerText); break; case "y": y = Convert.ToInt32(n2.InnerText); break; case "wall": wall = Convert.ToInt32(n2.InnerText); break; } } if(x != -1 && y != -1 && wall != -1) d.setPosition(wall,x,y,false); data.Add(d); } xml.Save(configPath+shortcutConfig); currentConfig = data; return data; }