|
From: | Gopal.V <address@hidden> |
Subject: | [Dotgnu-libs-commits] CVS: libxmlsharp/samples Makefile,NONE,1.1 builder.cs,NONE,1.1 ns.cs,NONE,1.1 ns.xml,NONE,1.1 struct.cs,NONE,1.1 struct.xml,NONE,1.1 tree.cs,NONE,1.1 tree.xml,NONE,1.1 |
Date: | Thu, 04 Jul 2002 19:45:39 -0400 |
Update of /cvsroot/dotgnu-libs/libxmlsharp/samples In directory subversions:/tmp/cvs-serv12763/samples Added Files: Makefile builder.cs ns.cs ns.xml struct.cs struct.xml tree.cs tree.xml Log Message: First Post --- NEW FILE --- CSCC=cscc ILRUN=ilrun all: Makefile dotgnu.xml.dll libxml_wrapper.so build build: tree.exe struct.exe builder.exe ns.exe .SUFFIXES: .cs .exe .cs.exe: $(CSCC) -o $@ -ldotgnu.xml.dll $< dotgnu.xml.dll: Makefile ../dotgnu.xml/dotgnu.xml.dll ln -sf ../dotgnu.xml/dotgnu.xml.dll . libxml_wrapper.so: Makefile ../wrapper/libxml_wrapper.so ln -sf ../wrapper/libxml_wrapper.so . clean: Makefile rm -rf tree.exe struct.exe builder.exe rm -rf dotgnu.xml.dll libxml_wrapper.so --- NEW FILE --- using dotgnu.xml; using System; public class DOMBuilder { static int indent=0; private static void printIndent() { for(int i=0;i<indent;i++) Console.Write(" "); } public static void printRecursive(XmlNode node) { printIndent(); Console.Write("+--"); Console.WriteLine(node.Name); if(node.GetFirstChild()!=null) { indent++; printRecursive(node.GetFirstChild()); indent--; } if(node.GetNextSibling()!=null) { printRecursive(node.GetNextSibling()); } } public static void Main() { XmlDoc dc=new XmlDoc(); XmlElement nd=new XmlElement("dotgnu"); XmlElement nd2=new XmlElement("pnet"); nd2.AddChild(new XmlCData("Hey I work here &")); nd2.AddChild(new XmlComment("so does rhys !")); nd.AddChild(nd2); XmlElement nd3=new XmlElement("phpgw"); nd3.AddChild(new XmlPI("php","echo \"phpgroupware\";")); nd.AddChild(nd3); dc.AddChild(nd); //dc.Compression = 3; //dc.SaveToFile("/tmp/xml.gz",1); Console.WriteLine(dc.DumpXml()); printRecursive(dc); } } --- NEW FILE --- using System; using dotgnu.xml; public class test { static int indent=0; static int nodes=0; private static void printIndent() { for(int i=0;i<indent;i++) Console.Write(" "); } public static void printRecursive(XmlNode node) { printIndent(); Console.WriteLine("<"+node.FQName+" "+node+">"); if(node.GetFirstChild()!=null) { indent+=2; printRecursive(node.GetFirstChild()); indent-=2; } if(node.GetNextSibling()!=null) { printRecursive(node.GetNextSibling()); } } public static void Main(String[] args) { String file="ns.xml"; if(args.Length==1) file=args[0]; XmlDoc dc=XmlParser.Parse(file); dc.Normalize(); printRecursive(dc); } } --- NEW FILE --- <?xml version="1.0"?> <dia:diagram xmlns:dia="http://www.lysator.liu.se/~alla/dia/"> <dia:diagramdata dia:testattr="test"/> </dia:diagram> --- NEW FILE --- using dotgnu.xml; using System; public class struct_dumper { public static void Main(String[] args) { String file="struct.xml"; if(args.Length==1) file=args[0]; XmlDoc dc=XmlParser.Parse(file); foreach(XmlNode st in dc.Children) { if(st.Name=="struct") { Console.WriteLine("struct {0}",((XmlElement)st).GetAttr("name")); Console.WriteLine("{"); foreach(XmlNode el in st.Children) { if(el.Name=="elem") { Console.WriteLine("{0} {1};", ((XmlElement)el).GetAttr("type"), ((XmlElement)el).GetAttr("name")); } } Console.WriteLine("}"); } } } } --- NEW FILE --- <?xml version="1.0"?> <struct name="student"> <elem name="name" type="char*"/> <elem name="age" type="int"/> <elem name="grade" type="char"/> </struct> --- NEW FILE --- using System; using dotgnu.xml; public class test { static int indent=0; static int nodes=0; private static void printIndent() { for(int i=0;i<indent;i++) Console.Write(" "); } public static void printRecursive(XmlNode node) { printIndent(); Console.Write("+--"); Console.Write("<"+node.Name+" "+node+" >\n"); nodes++; if(node.ElementType==XmlElementType.XML_ELEMENT_NODE) { XmlElement el=(XmlElement)node; indent+=4; foreach(XmlAttr ar in el.Attributes) { printIndent(); Console.Write("+--"); Console.WriteLine(ar.Name+" => "+ar.Value); } indent-=4; } if(node.GetFirstChild()!=null) { indent+=2; printRecursive(node.GetFirstChild()); indent-=2; } if(node.GetNextSibling()!=null) { printRecursive(node.GetNextSibling()); } } public static void Main(String[] args) { String file="tree.xml"; if(args.Length==1) file=args[0]; XmlDoc dc=XmlParser.Parse(file); Console.WriteLine("**********Before Normalization***********"); printRecursive(dc); Console.WriteLine(" == {0} Nodes",nodes); nodes=0; Console.WriteLine("***********After Normalization***********"); dc.Normalize(); printRecursive(dc); Console.WriteLine(" == {0} Nodes",nodes); } } --- NEW FILE --- <?xml version='1.0'?> <?checkpoint Md5sig="#ZXpqe122141334"?> <!--COMMENT!--> <data> <comment> <![CDATA[ ]]> </comment> <info nelems="3"> <name order="0" name="Name" type="String" value="libxml#"/> <license order="1" name="License" type="String" value="GPL"/> <author order="2" name="Author" type="String" value="Gopal"/> </info> </data>
[Prev in Thread] | Current Thread | [Next in Thread] |