private void Set(Stream ins) { XMLDocument doc = XMLParser.Parse(ins); XMLElement Pack = doc.GetRoot(); Set(Pack); }
protected override async Task <Action <AsyncCodeActivityContext> > ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken) { // Inputs var excelFilePath = ExcelFilePath.Get(context); var sapProcessName = SAPProcessName.Get(context); var xmlFolderPath = XMLFolderPath.Get(context); var xmlFilePath = string.Empty; XmlDocument doc = null; ExcelToXMLConverter excelToXMLConverter = new ExcelToXMLConverter(); if (!string.IsNullOrEmpty(xmlFolderPath)) { xmlFilePath = excelToXMLConverter.ConvertExcelToXMLFile(excelFilePath, sapProcessName, xmlFolderPath); } else { doc = excelToXMLConverter.ConvertExcelToXMLDocument(excelFilePath, sapProcessName); } // Outputs return((ctx) => { XMLDocument.Set(ctx, doc); XMLPath.Set(ctx, xmlFilePath); }); }
public static ConfigEmitter LoadEmitter(InputStream refs, ConfigEmitterFactory factory) { if (factory == null) { factory = new NewConfigEmitterFactory(); } try { XMLDocument document = XMLParser.Parse(refs); if (!document.GetRoot().GetName().Equals("emitter")) { throw new IOException("Not a particle emitter file"); } ConfigEmitter emitter = factory.CreateEmitter("new"); ElementToEmitter(document.GetRoot(), emitter); return(emitter); } catch (IOException e) { Log.Exception(e); throw e; } catch (Exception e) { Log.Exception(e); throw new IOException("Unable to load emitter"); } }
/*----------------------------------------------------*/ public XmlAttribute AddAttribute(XmlNode aNode, String aName, String aValue) { XmlAttribute aAttribute = XMLDocument.CreateAttribute(aName); aAttribute.Value = aValue; aNode.Attributes.Append(aAttribute); return(aAttribute); }
private void ParseSecondType(XMLDocument xmlDoc) { TargetPath = xmlDoc.Root.Children()[0].AttributeValue <string>("TargetPath"); SourcePath = xmlDoc.Root.Children()[0].AttributeValue <string>("SourcePath"); foreach (var mod in xmlDoc.Root.Children()[1].GetDictionary()) { Mods[(EncryptCompressMode)Enum.Parse(typeof(EncryptCompressMode), mod.Key)] = mod.Value; } IsParsed = true; }
/// <summary> /// Convert a Xml document into Json Object /// <summary> /// <param name="xml">Xml Document to convert</param> public Json Convert(XMLDocument xml) { // TODO : check xml if (isXmlRight(xml)) { r_json = JsonConvert.SerializeXmlNode(xml); buffer = r_json; return(r_json); } }
public static ParticleSystem LoadConfiguredSystem(InputStream refs, ConfigEmitterFactory factory, ParticleSystem system, LColor mask) { if (factory == null) { factory = new NewConfigEmitterFactory(); } try { XMLDocument document = XMLParser.Parse(refs); XMLElement element = document.GetRoot(); if (!element.GetName().Equals("system", System.StringComparison.InvariantCultureIgnoreCase)) { Log.DebugWrite("Not a particle system file"); } if (system == null) { system = new ParticleSystem("assets/particle.tga", 2000, mask); } bool additive = "true".Equals(element.GetAttribute("additive")); if (additive) { system.SetBlendingMode(ParticleSystem.BLEND_ADDITIVE); } else { system.SetBlendingMode(ParticleSystem.BLEND_COMBINE); } bool points = "true".Equals(element.GetAttribute("points")); system.SetUsePoints(points); List <XMLElement> List = element.List("emitter"); for (int i = 0; i < List.Count; i++) { XMLElement em = (XMLElement)List[i]; ConfigEmitter emitter = factory.CreateEmitter("new"); ElementToEmitter(em, emitter); system.AddEmitter(emitter); } system.SetRemoveCompletedEmitters(false); return(system); } catch (IOException e) { Log.Exception(e); } catch (Exception e) { Log.Exception(e); throw new IOException("Unable to load particle system config"); } return(system); }
private void TryParse(XMLDocument xmlDoc) { try { ParseFirstType(xmlDoc); } catch (Exception) { ParseSecondType(xmlDoc); } }
public WSDL(XMLDocument doc) { XmlNamespaceManager nsManager = new XmlNamespaceManager(doc.NameTable); nsManager.AddNamespace("wsdl", doc.DocumentElement.NamespaceURI); nsManager.AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); ParseTypes(doc, nsManager); ParseMessages(doc, nsManager); ParsePortTypes(doc, nsManager); ParseBindings(doc, nsManager); ParseServices(doc, nsManager); }
/// <summary> /// 获取余额接口 /// </summary> /// <param name="uid"></param> /// <param name="pwd"></param> /// <returns></returns> private string GetBalance(string uid, string pwd) { string Send_URL = "http://service.winic.org/webservice/public/remoney.asp?uid=" + uid + "&pwd=" + pwd + ""; MSXML2.XMLHTTP xmlhttp = new MSXML2.XMLHTTP(); xmlhttp.open("GET", Send_URL, false, null, null); xmlhttp.send(""); MSXML2.XMLDocument dom = new XMLDocument(); Byte[] b = (Byte[])xmlhttp.responseBody; string andy = System.Text.Encoding.GetEncoding("GB2312").GetString(b).Trim(); return(andy); }
private void ParseXML(string xmlData) { XMLDocument xDoc = new XMLDocument(); xDoc.Load(new StringReader(xmlData)); string xmlPathPattern = "//atlas/image"; XmlNodeList nodes = xDoc.SelectNodes(xmlPathPattern); foreach (XmlNode node in nodes) { TextureData data = ParseNode(node); m_sprites[data.name] = data; } }
public static XMLDocument GetXML(string KEY) { string file = ""; switch (KEY) { case "AA": file = Path.Combine(file, "AA.txt"); break; } var xmldoc = new XMLDocument(); xmldoc.Load(file); return(xmldoc); }
private static void TemplateMethod() { XMLDocument document = new XMLDocument(); document.Print(); document.PrintBody(); document.PrintHeader(); HTMLDocument document2 = new HTMLDocument(); document2.Print(); document2.PrintBody(); document2.PrintHeader(); Console.ReadKey(); }
protected override async Task <Action <AsyncCodeActivityContext> > ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken) { // Inputs var excelFilePath = ExcelFilePath.Get(context); var sapProcessName = SAPProcessName.Get(context); var xmlFolderPath = XMLFolderPath.Get(context); /////////////////////////// // Add execution logic HERE /////////////////////////// // Outputs return((ctx) => { XMLDocument.Set(ctx, null); XMLPath.Set(ctx, null); }); }
protected override async Task <Action <AsyncCodeActivityContext> > ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken) { // Inputs var pathToXML = PathToXML.Get(context); var xmlDocument = XMLDocument.Get(context); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xmlDocument.InnerXml); SAPXmlConverter sapXmlConverter = new SAPXmlConverter(); var dictionary = sapXmlConverter.ProcessXMLForSAPBapi(pathToXML, xmlDoc); // Outputs return((ctx) => { Dictionary.Set(ctx, dictionary); }); }
/// <summary> /// Creates a new instance of the XML parser with the specified document /// based on the given source manager. /// </summary> /// <param name="document">The document instance to be constructed.</param> /// <param name="source">The source to use.</param> internal XmlParser(XMLDocument document, SourceManager source) { tokenizer = new XmlTokenizer(source); tokenizer.ErrorOccurred += (s, ev) => { if (ErrorOccurred != null) { ErrorOccurred(this, ev); } }; started = false; doc = document; standalone = false; open = new List <Element>(); insert = XmlTreeMode.Initial; }
protected override async Task <Action <AsyncCodeActivityContext> > ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken) { // Inputs var excelfile = ExcelFile.Get(context); var xmlFilePathFolder = XMLFilePathFolder.Get(context); /////////////////////////// // Add execution logic HERE /////////////////////////// ExcelToXMLConverter // Outputs return((ctx) => { XMLDocument.Set(ctx, null); XMLFIlePath.Set(ctx, null); }); }
/// <summary> /// Runs the Validation with the given document. /// </summary> /// <param name="doc">The document to inspect.</param> /// <returns>True if the validation has been successful, otherwise false.</returns> public static Boolean Run(XMLDocument doc) { if (doc.Doctype == null || doc.Doctype.TypeDefinitions == null) { return(false); } var validator = new XmlValidator(); validator.Definition = doc.Doctype.TypeDefinitions; if (!validator.Definition.IsInvalid && doc.DocumentElement.NodeName == doc.Doctype.Name) { return(validator.Inspect(doc.DocumentElement)); } return(false); }
private string SendMsg(string uid, string pwd, string mob, string msg) { switch (SiteConfig.SiteOption.DefaultSMS) { case "3": return(""); default: string Send_URL = "http://service.winic.org/sys_port/gateway/?id=" + uid + "&pwd=" + pwd + "&to=" + mob + "&content=" + msg + "&time="; MSXML2.XMLHTTP xmlhttp = new MSXML2.XMLHTTP(); xmlhttp.open("GET", Send_URL, false, null, null); xmlhttp.send(""); MSXML2.XMLDocument dom = new XMLDocument(); Byte[] b = (Byte[])xmlhttp.responseBody; //string Flag = System.Text.ASCIIEncoding.UTF8.GetString(b, 0, b.Length); string andy = System.Text.Encoding.GetEncoding("GB2312").GetString(b).Trim(); return(andy); } }
/*----------------------------------------------------*/ public bool LoadFromXML(String aXML) { if (XMLDocument == null) { XMLDocument = new XmlDocument(); } //MessageBox.Show("FileName: " + aFileName); try { XMLDocument.LoadXml(aXML); DocElement = XMLDocument.DocumentElement; //MessageBox.Show("Opened XML"); } catch (Exception e) { //MessageBox.Show("Error: " + e.Message); Debug.WriteLine("Error: " + e.Message); } return(true); }
/*----------------------------------------------------*/ public bool Load(String aFileName) { if (XMLDocument == null) { XMLDocument = new XmlDocument(); } FileInfo aConfigFI; try { if (aFileName.IndexOf(".", 0) == -1) { aConfigFI = new FileInfo(aFileName + ".xml"); if (aConfigFI.Exists) { aFileName = aFileName + ".xml"; } else { aFileName = aFileName + ".config"; } } aConfigFI = new FileInfo(aFileName); if (!aConfigFI.Exists) { return(false); } XMLDocument.Load(aFileName); DocElement = XMLDocument.DocumentElement; //MessageBox.Show("Opened XML"); } catch (Exception e) { //MessageBox.Show("Error: " + e.Message); Debug.WriteLine("Error: " + e.Message); } return(true); }
public static void packAssetBundle() { DateTime time0 = DateTime.Now; // 清理输出目录 CreateOrClearOutPath(); // 清理之前设置过的bundleName ClearAssetBundleName(); // 设置bunderName bundleMap.Clear(); List <string> resList = new List <string>(); GetAllSubResDirs(RES_SRC_PATH, resList); foreach (string dir in resList) { setAssetBundleName(dir); } // 打包 BuildPipeline.BuildAssetBundles(RES_OUTPUT_PATH, BuildAssetBundleOptions.ChunkBasedCompression, BuildTarget.StandaloneWindows); AssetDatabase.Refresh(); // 构建依赖关系 AssetBundle assetBundle = AssetBundle.LoadFromFile(CommonDefine.F_STREAMING_ASSETS_PATH + "StreamingAssets"); AssetBundleManifest mainfest = assetBundle.LoadAsset <AssetBundleManifest>("AssetBundleManifest"); string[] assetBundleNameList = mainfest.GetAllAssetBundles(); foreach (string bundle in assetBundleNameList) { string bundleName = bundle; string[] deps = mainfest.GetAllDependencies(bundleName); StringUtility.rightToLeft(ref bundleName); foreach (string dep in deps) { string depName = dep; StringUtility.rightToLeft(ref depName); if (bundleMap.ContainsKey(dep)) { List <AssetBuildBundleInfo> infoList = bundleMap[bundleName]; foreach (AssetBuildBundleInfo info in infoList) { info.AddDependence(depName); } } } } // 生成XML doc = new XMLDocument(); doc.startObject("files"); foreach (KeyValuePair <string, AssetBuildBundleInfo> pair in fileMap) { AssetBuildBundleInfo info = pair.Value; doc.startObject("file"); doc.createElement("bundleName", info.bundleName); doc.createElement("fileName", info.fileName); doc.createElement("assetName", info.assetName); if (info.dependencies != null) { doc.startObject("deps"); foreach (string dep in info.dependencies) { doc.createElement("dep", dep); } doc.endObject("deps"); } doc.endObject("file"); } doc.endObject("files"); FileStream fs = new FileStream(Path.Combine(RES_OUTPUT_PATH, "StreamingAssets.xml"), FileMode.Create); byte[] data = System.Text.Encoding.UTF8.GetBytes(doc.ToString()); fs.Write(data, 0, data.Length); fs.Flush(); fs.Close(); UnityUtility.messageBox("资源打包结束! 耗时 : " + (DateTime.Now - time0), false); }
private void createPath(List<string> path, string val) { if (path.Count == 0) { // We are at the leaf; we create this leaf XMLDocument leaf = new XMLDocument(); leaf.m_type = NodeType.TEXT; leaf.m_elementName = val; this.m_children.Add(leaf); return; } string firstElement = path[0]; bool added = false; path.RemoveAt(0); foreach (XMLDocument xd in m_children) { if (xd.m_elementName != firstElement) { continue; } xd.createPath(path, val); added = true; break; } if (!added) { XMLDocument xd = new XMLDocument(); xd.m_elementName = firstElement; xd.createPath(path, val); m_children.Add(xd); } }
protected static List<XMLDocument> parse(string s, bool ignoreWhiteSpace) { Regex r = null; MatchCollection m = null; int inside_begin = 0, inside_end = 0, tag_end = 0; bool tag_has_children, parse_error = false; XMLDocument xd; List<XMLDocument> out_children = new List<XMLDocument>(); // This is an "XML declaration" tag: we trim it if (s.Length >= 5 && s.Substring(0, 5) == "<?xml") { int new_beg = s.IndexOf(">") + 1; s = s.Substring(new_beg).Trim(); } while (s.Length > 0 && !parse_error) { xd = new XMLDocument(); inside_begin = 0; inside_end = 0; tag_end = 0; tag_has_children = true; r = new Regex("^<\\s*([^\\s>]+)\\s*([^>]*)>"); m = r.Matches(s); if (m.Count > 0) { Match m2 = m[0]; GroupCollection g = m2.Groups; // Opening tag found at first position xd.m_elementName = g[1].ToString(); inside_begin = g[2].Index + g[2].ToString().Length + 1; if (g[2].ToString().EndsWith("/")) { // Self-closing tag // TODOC#: vérifier si les bornes sont exactes en C# inside_end = g[g.Count - 1].Index; tag_end = g[g.Count - 1].Index; tag_has_children = false; } else { r = new Regex("<\\s*(/{0,1})" + xd.m_elementName + "\\s*>"); m = r.Matches(s.Substring(inside_begin)); int level = 1; bool tag_found = false; foreach (Match m3 in m) { g = m3.Groups; if (g[1].ToString().StartsWith("/")) { // Closing tag level--; } if (g[1].ToString().Length == 0) { // Closing tag level++; } if (level == 0) { // Matching closing tag inside_end = inside_begin + m[0].Index; tag_end = inside_begin + m[0].Index + m[0].ToString().Length; tag_found = true; break; } } // If we get here, we didn't find matching closing tag: // parse error if (!tag_found) { // Do nothing with it parse_error = true; } } } else { // No opening tag at first position: this is text r = new Regex("<"); m = r.Matches(s); if (m.Count > 0) { inside_end = m[0].Index; } else { inside_end = s.Length; } tag_end = inside_end; string inside = s.Substring(inside_begin, inside_end); if (ignoreWhiteSpace) { inside = inside.Trim(); } if (inside.Length == 0) { // This text is null, don't create an element xd = null; } else { xd.m_elementName = inside; xd.m_type = NodeType.TEXT; tag_has_children = false; } } if (!parse_error) { string inside = s.Substring(inside_begin, (inside_end - inside_begin)); s = s.Substring(tag_end); if (xd != null) { if (tag_has_children) { xd.m_children = parse (inside, ignoreWhiteSpace); } out_children.Add(xd); } } } return out_children; }
/** * Evaluates an XPath expression on a document. See the class documentation * for a description of the supported syntax. In case of a syntax error, the * expression evaluates to false as soon as the method's (very) basic parser * no longer recognizes how to read the string. * * @param e * The XPath expression * @return A list of nodes, corresponding to the result of the operation. * The method always returns a list, even when the expected result * is true or false. In such a case, the list contains only one * element, a node of type TRUE or FALSE (not to be confused with a * <em>text</em> node whose text is "TRUE" or "FALSE"). Hence an * empty list is just an empty list of nodes, it should not be * confused with FALSE. */ public List<XMLDocument> evaluateXPath(string e) { Regex r; MatchCollection m; XMLDocument xd_left, xd_right, xd_false, xd_true; string path_left = "", path_right = ""; List<XMLDocument> xdOut = new List<XMLDocument>(); List<XMLDocument> left, right; // Creates element false xd_false = new XMLDocument(); xd_false.m_type = NodeType.FALSE; // Creates element true xd_true = new XMLDocument(); xd_true.m_type = NodeType.TRUE; // Get left path r = new Regex("(^[^\\s=]+)={0,1}"); m = r.Matches(e); if (m.Count == 0) { // Parse error: return false xdOut.Add(xd_false); return xdOut; } Match m2 = m[0]; GroupCollection g = m2.Groups; path_left = g[1].ToString(); e = e.Substring(m[0].Index + m[0].Length).Trim(); left = getPath(path_left); if (e.Length == 0) { // Nothing else: return subtree return left; } // Check if equality if (e.Length > 0 && !e.StartsWith("=")) { // Parse error: return false xdOut.Add(xd_false); return xdOut; } // Remove = sign e = e.Substring(1).Trim(); // Check if constant if (e.StartsWith("\"")) { r = new Regex("\"([^=]*)\""); m = r.Matches(e); if (m.Count == 0) { // Parse error: return false xdOut.Add(xd_false); return xdOut; } m2 = m[0]; g = m2.Groups; path_right = g[1].ToString(); if (left.Count != 1) { // LHS is a set of nodes and RHS is constant xdOut.Add(xd_false); return xdOut; } if (left[0].m_type != NodeType.TEXT) { // LHS is not text xdOut.Add(xd_false); return xdOut; } if (path_right != left[0].m_elementName) { // LHS and RHS text, but not same text xdOut.Add(xd_false); return xdOut; } xdOut.Add(xd_true); return xdOut; } else { // RHS is a path path_right = e; right = getPath(path_right); if (left.Count != 1 || right.Count != 1) { // One of the sides is not a single node xdOut.Add(xd_false); return xdOut; } xd_left = left[0]; xd_right = right[0]; if (xd_left.m_type != NodeType.TEXT || xd_right.m_type != NodeType.TEXT) { // One of the sides is not a text node xdOut.Add(xd_false); return xdOut; } if (xd_left.m_elementName != xd_right.m_elementName) { // LHS and RHS have different texts xdOut.Add(xd_false); return xdOut; } xdOut.Add(xd_true); return xdOut; } }
/*----------------------------------------------------*/ public XmlNode CreateSortNode() { return(XMLDocument.CreateNode(XmlNodeType.Element, "Sort", "")); }
public LTextureList(Stream ins0) { this.imageList = new Dictionary <string, ImageData>(10); this.autoExpand = false; this.visible = true; int index = 0; string x = "x", y = "y", w = "w", h = "h"; string scale = "scale", src = "src", maskName = "mask", empty = "empty"; string name = "name", filterName = "filter", n = "nearest", l = "linear"; XMLDocument doc = XMLParser.Parse(ins0); List <XMLElement> images = doc.GetRoot().Find("image"); if (images.Count > 0) { IEnumerator <XMLElement> it = images.GetEnumerator(); for (; it.MoveNext();) { XMLElement ele = it.Current; if (ele != null) { ImageData data = new ImageData(); data.x = ele.GetIntAttribute(x, 0); data.y = ele.GetIntAttribute(y, 0); data.w = ele.GetIntAttribute(w, 0); data.h = ele.GetIntAttribute(h, 0); data.scale = ele.GetFloatAttribute(scale, 0); data.xref = ele.GetAttribute(src, empty); XMLElement mask = ele.GetChildrenByName(maskName); if (mask != null) { int r = mask.GetIntAttribute("r", 0); int g = mask.GetIntAttribute("g", 0); int b = mask.GetIntAttribute("b", 0); int a = mask.GetIntAttribute("a", 0); data.mask = new LColor(r, g, b, a); } else { data.mask = null; } string filter = ele.GetAttribute(filterName, n); if (filter.Equals(n)) { data.scaleType = 0; } if (filter.Equals(l)) { data.scaleType = 1; } data.index = index; XMLElement parent = ele.GetParent(); if (parent != null) { CollectionUtils.Put(imageList, parent.GetAttribute(name, empty), data); index++; } } } } this.count = imageList.Count; this.values = new LTextureObject[count]; }
protected static XMLDocument getSatisfyingMessage(GeneratorNode gn) { XMLDocument xd = new XMLDocument(); if (gn == null) { return xd; } HashSet<OPlus> opluses = gn.getOPluses(); foreach (OPlus op in opluses) { if (op.getOperand().Equals(Operator.m_trueAtom) || op.getOperand().Equals(Operator.m_falseAtom)) { // This only asserts that the path should exist continue; } xd.createPath(op.getQualifier(), op.getOperand().ToString()); } return xd; }
/// <summary> /// Creates a new builder with the specified source. /// </summary> /// <param name="source">The code manager.</param> /// <param name="document">The document to fill.</param> DocumentBuilder(SourceManager source, XMLDocument document) { parser = new XmlParser(document, source); parser.ErrorOccurred += ParseErrorOccurred; }
private void Load(Stream ins, string tileSetsLocation) { screenRect = LSystem.screenRect; tilesLocation = tileSetsLocation; try { XMLDocument doc = XMLParser.Parse(ins); XMLElement docElement = doc.GetRoot(); string orient = docElement.GetAttribute("orientation", ""); if (!"orthogonal".Equals(orient)) { throw new Exception( "Only orthogonal maps supported, found " + orient); } width = docElement.GetIntAttribute("width", 0); height = docElement.GetIntAttribute("height", 0); tileWidth = docElement.GetIntAttribute("tilewidth", 0); tileHeight = docElement.GetIntAttribute("tileheight", 0); XMLElement propsElement = docElement .GetChildrenByName("properties"); if (propsElement != null) { props = new TMXProperty(); List <XMLElement> property = propsElement.List("property"); for (int i = 0; i < property.Count; i++) { XMLElement propElement = property[i]; string name = propElement.GetAttribute("name", null); string value_ren = propElement.GetAttribute("value", null); props.SetProperty(name, value_ren); } } if (loadTileSets) { TMXTileSet tileSet = null; TMXTileSet lastSet = null; List <XMLElement> setNodes = docElement.List("tileset"); for (int i_0 = 0; i_0 < setNodes.Count; i_0++) { XMLElement current = setNodes[i_0]; tileSet = new TMXTileSet(this, current, true); tileSet.index = i_0; if (lastSet != null) { lastSet.SetLimit(tileSet.firstGID - 1); } lastSet = tileSet; CollectionUtils.Add(tileSets, tileSet); } } List <XMLElement> layerNodes = docElement.List("layer"); for (int i_1 = 0; i_1 < layerNodes.Count; i_1++) { XMLElement current_2 = layerNodes[i_1]; TMXLayer layer = new TMXLayer(this, current_2); layer.index = i_1; CollectionUtils.Add(layers, layer); } List <XMLElement> objectGroupNodes = docElement .List("objectgroup"); for (int i_3 = 0; i_3 < objectGroupNodes.Count; i_3++) { XMLElement current_4 = objectGroupNodes[i_3]; TMXTileGroup objectGroup = new TMXTileGroup(current_4); objectGroup.index = i_3; CollectionUtils.Add(objectGroups, objectGroup); } defWidth = (int)(screenRect.GetWidth() / tileWidth); defHeight = (int)(screenRect.GetHeight() / tileHeight); } catch (Exception ex) { Console.Error.WriteLine(ex.StackTrace); throw new Exception("Failed to parse map", ex); } }
/// <summary> /// Creates a new instance of the XML parser with the specified document /// based on the given stream. /// </summary> /// <param name="document">The document instance to be constructed.</param> /// <param name="stream">The stream to use as source.</param> public XmlParser(XMLDocument document, Stream stream) : this(document, new SourceManager(stream)) { }
/// <summary> /// Creates a new instance of the XML parser with the specified document /// based on the given source. /// </summary> /// <param name="document">The document instance to be constructed.</param> /// <param name="source">The source code as a string.</param> public XmlParser(XMLDocument document, String source) : this(document, new SourceManager(source)) { }
public WatcherMessage(string s) : this() { m_xd = new XMLDocument(s); }
public TMXTileSet(TMXTiledMap map, XMLElement element, bool loadImage) { this.map = map; this.name = element.GetAttribute("name", null); this.firstGID = element.GetIntAttribute("firstgid", 0); string source = element.GetAttribute("source", ""); if (!"".Equals(source)) { try { Stream ins0 = Resources.OpenStream(map.GetTilesLocation() + "/" + source); XMLDocument doc = XMLParser.Parse(ins0); XMLElement docElement = doc.GetRoot(); element = docElement; } catch (Exception e) { Loon.Utils.Debug.Log.Exception(e); throw new Exception(this.map.tilesLocation + "/" + source); } } string tileWidthString = element.GetAttribute("tilewidth", ""); string tileHeightString = element.GetAttribute("tileheight", ""); if (tileWidthString.Length == 0 || tileHeightString.Length == 0) { throw new Exception( "tileWidthString.length == 0 || tileHeightString.length == 0"); } tileWidth = Int32.Parse(tileWidthString); tileHeight = Int32.Parse(tileHeightString); string sv = element.GetAttribute("spacing", ""); if ((sv != null) && (!"".Equals(sv))) { tileSpacing = Int32.Parse(sv); } string mv = element.GetAttribute("margin", ""); if ((mv != null) && (!"".Equals(mv))) { tileMargin = Int32.Parse(mv); } List <XMLElement> list = element.List("image"); XMLElement imageNode = list[0]; string fileName = imageNode.GetAttribute("source", null); LColor trans = null; string t = imageNode.GetAttribute("trans", null); if ((t != null) && (t.Length > 0)) { trans = new LColor(((uint)Convert.ToInt32(t, 16))); } if (loadImage) { string path = map.GetTilesLocation() + "/" + fileName; LTexture image; if (trans != null) { image = TextureUtils.FilterColor(path, trans); } else { image = LTextures.LoadTexture(path); } SetTileSetImage(image); } List <XMLElement> elements = element.List("tile"); for (int i = 0; i < elements.Count; i++) { XMLElement tileElement = elements[i]; int id = tileElement.GetIntAttribute("id", 0); id += firstGID; TMXProperty tileProps = new TMXProperty(); XMLElement propsElement = tileElement .GetChildrenByName("properties"); List <XMLElement> properties = propsElement.List("property"); for (int p = 0; p < properties.Count; p++) { XMLElement propElement = properties[p]; string name_1 = propElement.GetAttribute("name", null); string value_ren = propElement.GetAttribute("value", null); tileProps.SetProperty(name_1, value_ren); } CollectionUtils.Put(props, id, tileProps); } }
public static NSObject Parse(System.IO.Stream s) { XMLDocument doc = XMLParser.Parse(s); return(ParseObject(doc.GetRoot().GetFirstChild().GetFirstChild())); }