summaryrefslogtreecommitdiff
path: root/trunk/reprap/miscellaneous/python-beanshell-scripts/documentation/skeinforge_tools.skeinforge_utilities.xml_simple_parser.html
blob: 7aba8d35eed2acdebf472c58f5348282bdee4237 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124

<!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module skeinforge_tools.skeinforge_utilities.xml_simple_parser</title>
</head><body bgcolor="#f0f0f8">

<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong><a href="skeinforge_tools.html"><font color="#ffffff">skeinforge_tools</font></a>.<a href="skeinforge_tools.skeinforge_utilities.html"><font color="#ffffff">skeinforge_utilities</font></a>.xml_simple_parser</strong></big></big> ($Date: 2008/21/04 $)</font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/enrique/Desktop/backup/babbleold/script/reprap/pyRepRap/skeinforge_tools/skeinforge_utilities/xml_simple_parser.py">/home/enrique/Desktop/backup/babbleold/script/reprap/pyRepRap/skeinforge_tools/skeinforge_utilities/xml_simple_parser.py</a></font></td></tr></table>
    <p><tt>The xml_simple_parser.py script is an xml parser that can parse a line separated xml text.<br>
 <br>
This xml parser will read a line seperated xml text and produce a tree of the xml with a root element.  Each element can have an attribute table, children, a class name, parents, text and a link to the root element.<br>
 <br>
This example gets an xml tree for the xml file boolean.xml.  This example is run in a terminal in the folder which contains boolean.xml and xml_simple_parser.py.<br>
 <br>
 <br>
&gt; python<br>
Python 2.5.1 (r251:54863, Sep 22 2007, 01:43:31)<br>
[GCC 4.2.1 (SUSE Linux)] on linux2<br>
Type "help", "copyright", "credits" or "license" for more information.<br>
&gt;&gt;&gt; file = open( 'boolean.xml', 'r' )<br>
&gt;&gt;&gt; xmlText = file.read()<br>
&gt;&gt;&gt; file.close()<br>
&gt;&gt;&gt; from xml_simple_parser import <a href="#XMLSimpleParser">XMLSimpleParser</a><br>
&gt;&gt;&gt; xmlParser = <a href="#XMLSimpleParser">XMLSimpleParser</a>( xmlText )<br>
&gt;&gt;&gt; print( xmlParser )<br>
  ?xml, {'version': '1.0'}<br>
  ArtOfIllusion, {'xmlns:bf': '//babelfiche/codec', 'version': '2.0', 'fileversion': '3'}<br>
  Scene, {'bf:id': 'theScene'}<br>
  materials, {'bf:elem-type': 'java.lang.Object', 'bf:list': 'collection', 'bf:id': '1', 'bf:type': 'java.util.Vector'}<br>
..<br>
many more lines of the xml tree<br>
..</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#fffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
    
<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="__init__.html">__init__</a><br>
</td><td width="25%" valign=top><a href="skeinforge_tools.skeinforge_utilities.euclidean.html">skeinforge_tools.skeinforge_utilities.euclidean</a><br>
</td><td width="25%" valign=top><a href="skeinforge_tools.skeinforge_utilities.gcodec.html">skeinforge_tools.skeinforge_utilities.gcodec</a><br>
</td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
    
<tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="skeinforge_tools.skeinforge_utilities.xml_simple_parser.html#XMLElement">XMLElement</a>
</font></dt><dt><font face="helvetica, arial"><a href="skeinforge_tools.skeinforge_utilities.xml_simple_parser.html#XMLSimpleParser">XMLSimpleParser</a>
</font></dt></dl>
 <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="XMLElement">class <strong>XMLElement</strong></a></font></td></tr>
    
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt>An&nbsp;xml&nbsp;element.<br>&nbsp;</tt></td></tr>
<tr><td>&nbsp;</td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="XMLElement-__init__"><strong>__init__</strong></a>(self)</dt><dd><tt>Add&nbsp;empty&nbsp;lists.</tt></dd></dl>

<dl><dt><a name="XMLElement-__repr__"><strong>__repr__</strong></a>(self)</dt><dd><tt>Get&nbsp;the&nbsp;string&nbsp;representation&nbsp;of&nbsp;this&nbsp;XML&nbsp;element.</tt></dd></dl>

<dl><dt><a name="XMLElement-addAttribute"><strong>addAttribute</strong></a>(self, word)</dt><dd><tt>Set&nbsp;the&nbsp;attribute&nbsp;table&nbsp;to&nbsp;the&nbsp;split&nbsp;line.</tt></dd></dl>

<dl><dt><a name="XMLElement-getChildrenWithClassName"><strong>getChildrenWithClassName</strong></a>(self, className)</dt><dd><tt>Get&nbsp;the&nbsp;children&nbsp;which&nbsp;have&nbsp;the&nbsp;given&nbsp;class&nbsp;name.</tt></dd></dl>

<dl><dt><a name="XMLElement-getFirstChildWithClassName"><strong>getFirstChildWithClassName</strong></a>(self, className)</dt><dd><tt>Get&nbsp;the&nbsp;first&nbsp;child&nbsp;which&nbsp;has&nbsp;the&nbsp;given&nbsp;class&nbsp;name.</tt></dd></dl>

<dl><dt><a name="XMLElement-getSubChildWithID"><strong>getSubChildWithID</strong></a>(self, idReference)</dt><dd><tt>Get&nbsp;the&nbsp;child&nbsp;which&nbsp;has&nbsp;the&nbsp;idReference.</tt></dd></dl>

<dl><dt><a name="XMLElement-parseReplacedLine"><strong>parseReplacedLine</strong></a>(self, line, parents)</dt><dd><tt>Parse&nbsp;replaced&nbsp;line.</tt></dd></dl>

</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="XMLSimpleParser">class <strong>XMLSimpleParser</strong></a></font></td></tr>
    
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt>A&nbsp;simple&nbsp;xml&nbsp;parser.<br>&nbsp;</tt></td></tr>
<tr><td>&nbsp;</td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="XMLSimpleParser-__init__"><strong>__init__</strong></a>(self, xmlText)</dt><dd><tt>Add&nbsp;empty&nbsp;lists.</tt></dd></dl>

<dl><dt><a name="XMLSimpleParser-__repr__"><strong>__repr__</strong></a>(self)</dt><dd><tt>Get&nbsp;the&nbsp;string&nbsp;representation&nbsp;of&nbsp;this&nbsp;parser.</tt></dd></dl>

<dl><dt><a name="XMLSimpleParser-parseLine"><strong>parseLine</strong></a>(self, line)</dt><dd><tt>Parse&nbsp;a&nbsp;gcode&nbsp;line&nbsp;and&nbsp;add&nbsp;it&nbsp;to&nbsp;the&nbsp;inset&nbsp;skein.</tt></dd></dl>

</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
    
<tr><td bgcolor="#55aa55"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><strong>__author__</strong> = 'Enrique Perez (perez_enrique@yahoo.com)'<br>
<strong>__credits__</strong> = 'Nophead &lt;http://hydraraptor.blogspot.com/&gt;<font color="#c040c0">\n</font>Art of Illusion &lt;http://www.artofillusion.org/&gt;'<br>
<strong>__date__</strong> = '$Date: 2008/21/04 $'<br>
<strong>__license__</strong> = 'GPL 3.0'<br>
<strong>absolute_import</strong> = _Feature((2, 5, 0, 'alpha', 1), (2, 7, 0, 'alpha', 0), 16384)</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#7799ee">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Author</strong></big></font></td></tr>
    
<tr><td bgcolor="#7799ee"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%">Enrique&nbsp;Perez&nbsp;(perez_enrique@yahoo.com)</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#7799ee">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Credits</strong></big></font></td></tr>
    
<tr><td bgcolor="#7799ee"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%">Nophead&nbsp;&lt;<a href="http://hydraraptor.blogspot.com/">http://hydraraptor.blogspot.com/</a>&gt;<br>
Art&nbsp;of&nbsp;Illusion&nbsp;&lt;<a href="http://www.artofillusion.org/">http://www.artofillusion.org/</a>&gt;</td></tr></table>
</body></html>