📄 xml.htm
字号:
<FONT color='gray'>237| </FONT> <FONT color='darkblue'><B>return</B></FONT> <FONT color='darkblue'><B>new</B></FONT> <FONT color='purple'>pi</FONT><FONT color='dimgray'>(</FONT>v<FONT color='dimgray'>)</FONT><FONT color='dimgray'>;</FONT>
<FONT color='gray'>238| </FONT> <FONT color='dimgray'>}</FONT>
<FONT color='gray'>239| </FONT> <FONT color='darkblue'><B>case</B></FONT> <FONT color='maroon'>'!'</FONT><FONT color='dimgray'>:</FONT>
<FONT color='gray'>240| </FONT> <FONT color='dimgray'>{</FONT>
<FONT color='gray'>241| </FONT> c <FONT color='dimgray'>=</FONT> _in<FONT color='dimgray'>.</FONT><FONT color='purple'>get</FONT><FONT color='dimgray'>(</FONT><FONT color='dimgray'>)</FONT><FONT color='dimgray'>;</FONT>
<FONT color='gray'>242| </FONT> <FONT color='darkblue'><B>if</B></FONT> <FONT color='purple'></FONT><FONT color='dimgray'>(</FONT> c <FONT color='dimgray'>==</FONT> <FONT color='maroon'>'-'</FONT> <FONT color='dimgray'>)</FONT>
<FONT color='gray'>243| </FONT> <FONT color='dimgray'>{</FONT>
<FONT color='gray'>244| </FONT> <FONT color='darkblue'><B>if</B></FONT><FONT color='dimgray'>(</FONT>_in<FONT color='dimgray'>.</FONT><FONT color='purple'>get</FONT><FONT color='dimgray'>(</FONT><FONT color='dimgray'>)</FONT> <FONT color='dimgray'>!=</FONT> <FONT color='maroon'>'-'</FONT><FONT color='dimgray'>)</FONT> <FONT color='darkblue'><B>throw</B></FONT> string<FONT color='dimgray'>::</FONT><FONT color='purple'>printf</FONT><FONT color='dimgray'>(</FONT><FONT color='maroon'>"bad comment: %s"</FONT><FONT color='dimgray'>,</FONT>_in<FONT color='dimgray'>.</FONT><FONT color='purple'>get</FONT><FONT color='dimgray'>(</FONT><FONT color='maroon'>"\n"</FONT><FONT color='dimgray'>)</FONT><FONT color='dimgray'>)</FONT><FONT color='dimgray'>;</FONT>
<FONT color='gray'>245| </FONT> <FONT color='darkblue'><B>var</B></FONT> v <FONT color='dimgray'>=</FONT> _in<FONT color='dimgray'>.</FONT><FONT color='purple'>get</FONT><FONT color='dimgray'>(</FONT><FONT color='maroon'>"-->"</FONT><FONT color='dimgray'>)</FONT><FONT color='dimgray'>;</FONT>
<FONT color='gray'>246| </FONT> <FONT color='darkblue'><B>return</B></FONT> <FONT color='darkblue'><B>new</B></FONT> <FONT color='purple'>comment</FONT><FONT color='dimgray'>(</FONT>v<FONT color='dimgray'>)</FONT><FONT color='dimgray'>;</FONT>
<FONT color='gray'>247| </FONT> <FONT color='dimgray'>}</FONT>
<FONT color='gray'>248| </FONT> <FONT color='darkblue'><B>else</B></FONT> <FONT color='darkblue'><B>if</B></FONT> <FONT color='purple'></FONT><FONT color='dimgray'>(</FONT> c <FONT color='dimgray'>==</FONT> <FONT color='maroon'>'['</FONT> <FONT color='dimgray'>)</FONT> <FONT color='dimgray'>{</FONT>
<FONT color='gray'>249| </FONT> <FONT color='darkblue'><B>var</B></FONT> v <FONT color='dimgray'>=</FONT> _in<FONT color='dimgray'>.</FONT><FONT color='purple'>get</FONT><FONT color='dimgray'>(</FONT><FONT color='maroon'>"CDATA["</FONT><FONT color='dimgray'>,</FONT><FONT color='maroon'>"\n"</FONT><FONT color='dimgray'>)</FONT><FONT color='dimgray'>;</FONT>
<FONT color='gray'>250| </FONT> <FONT color='darkblue'><B>if</B></FONT><FONT color='dimgray'>(</FONT>v<FONT color='dimgray'>)</FONT> <FONT color='darkblue'><B>throw</B></FONT> string<FONT color='dimgray'>::</FONT><FONT color='purple'>printf</FONT><FONT color='dimgray'>(</FONT><FONT color='maroon'>"expecting:'CDATA[', got:%s"</FONT><FONT color='dimgray'>,</FONT>v<FONT color='dimgray'>)</FONT><FONT color='dimgray'>;</FONT>
<FONT color='gray'>251| </FONT> v <FONT color='dimgray'>=</FONT> _in<FONT color='dimgray'>.</FONT><FONT color='purple'>get</FONT><FONT color='dimgray'>(</FONT><FONT color='maroon'>"]]>"</FONT><FONT color='dimgray'>)</FONT><FONT color='dimgray'>;</FONT>
<FONT color='gray'>252| </FONT> <FONT color='darkblue'><B>return</B></FONT> <FONT color='darkblue'><B>new</B></FONT> <FONT color='purple'>cdata</FONT><FONT color='dimgray'>(</FONT>v<FONT color='dimgray'>)</FONT><FONT color='dimgray'>;</FONT>
<FONT color='gray'>253| </FONT> <FONT color='dimgray'>}</FONT>
<FONT color='gray'>254| </FONT> <FONT color='darkblue'><B>else</B></FONT> <FONT color='darkblue'><B>if</B></FONT><FONT color='dimgray'>(</FONT> c <FONT color='dimgray'>==</FONT> <FONT color='maroon'>'D'</FONT> <FONT color='dimgray'>)</FONT>
<FONT color='gray'>255| </FONT> <FONT color='dimgray'>{</FONT>
<FONT color='gray'>256| </FONT> <FONT color='green'>//skip doctype definition</FONT>
<FONT color='gray'>257| </FONT> _in<FONT color='dimgray'>.</FONT><FONT color='purple'>get</FONT><FONT color='dimgray'>(</FONT><FONT color='maroon'>"OCTYPE"</FONT><FONT color='dimgray'>)</FONT><FONT color='dimgray'>;</FONT>
<FONT color='gray'>258| </FONT> _in<FONT color='dimgray'>.</FONT><FONT color='purple'>get</FONT><FONT color='dimgray'>(</FONT><FONT color='maroon'>"]"</FONT><FONT color='dimgray'>)</FONT><FONT color='dimgray'>;</FONT>_in<FONT color='dimgray'>.</FONT><FONT color='purple'>get</FONT><FONT color='dimgray'>(</FONT><FONT color='maroon'>">"</FONT><FONT color='dimgray'>)</FONT><FONT color='dimgray'>;</FONT>
<FONT color='gray'>259| </FONT> <FONT color='darkblue'><B>return</B></FONT> <FONT color='darkblue'><B>true</B></FONT><FONT color='dimgray'>;</FONT>
<FONT color='gray'>260| </FONT> <FONT color='dimgray'>}</FONT>
<FONT color='gray'>261| </FONT> <FONT color='darkblue'><B>else</B></FONT>
<FONT color='gray'>262| </FONT> <FONT color='darkblue'><B>throw</B></FONT> string<FONT color='dimgray'>::</FONT><FONT color='purple'>printf</FONT><FONT color='dimgray'>(</FONT><FONT color='maroon'>"expecting comment or cdata, got '%c'"</FONT><FONT color='dimgray'>,</FONT>c<FONT color='dimgray'>)</FONT><FONT color='dimgray'>;</FONT>
<FONT color='gray'>263| </FONT> <FONT color='dimgray'>}</FONT> <FONT color='darkblue'><B>break</B></FONT><FONT color='dimgray'>;</FONT>
<FONT color='gray'>264| </FONT> <FONT color='darkblue'><B>default</B></FONT><FONT color='dimgray'>:</FONT>
<FONT color='gray'>265| </FONT> <FONT color='dimgray'>{</FONT>
<FONT color='gray'>266| </FONT> <FONT color='darkblue'><B>var</B></FONT> atts_map<FONT color='dimgray'>;</FONT>
<FONT color='gray'>267| </FONT> _got_eot <FONT color='dimgray'>=</FONT> <FONT color='darkblue'><B>false</B></FONT><FONT color='dimgray'>;</FONT>
<FONT color='gray'>268| </FONT> <FONT color='darkblue'><B>var</B></FONT> name <FONT color='dimgray'>=</FONT> <FONT color='purple'>intern</FONT><FONT color='dimgray'>(</FONT> <FONT color='darkblue'><B>new</B></FONT> <FONT color='purple'>string</FONT><FONT color='dimgray'>(</FONT>c<FONT color='dimgray'>)</FONT> <FONT color='dimgray'>+</FONT> _in<FONT color='dimgray'>.</FONT><FONT color='purple'>get</FONT><FONT color='dimgray'>(</FONT><FONT color='maroon'>' '</FONT><FONT color='dimgray'>,</FONT><FONT color='maroon'>"/>"</FONT><FONT color='dimgray'>,</FONT><FONT color='maroon'>'>'</FONT><FONT color='dimgray'>)</FONT><FONT color='dimgray'>.</FONT><FONT color='purple'>trim</FONT><FONT color='dimgray'>(</FONT><FONT color='dimgray'>)</FONT> <FONT color='dimgray'>)</FONT><FONT color='dimgray'>;</FONT>
<FONT color='gray'>269| </FONT> <FONT color='darkblue'><B>if</B></FONT><FONT color='dimgray'>(</FONT>_in<FONT color='dimgray'>.</FONT>get_match <FONT color='dimgray'>==</FONT> <FONT color='red'>1</FONT><FONT color='dimgray'>)</FONT> atts_map <FONT color='dimgray'>=</FONT> <FONT color='purple'>compile_atts</FONT><FONT color='dimgray'>(</FONT>_in<FONT color='dimgray'>)</FONT><FONT color='dimgray'>;</FONT>
<FONT color='gray'>270| </FONT> <FONT color='darkblue'><B>else</B></FONT> <FONT color='darkblue'><B>if</B></FONT><FONT color='dimgray'>(</FONT>_in<FONT color='dimgray'>.</FONT>get_match <FONT color='dimgray'>==</FONT> <FONT color='red'>2</FONT><FONT color='dimgray'>)</FONT> _got_eot <FONT color='dimgray'>=</FONT> <FONT color='darkblue'><B>true</B></FONT><FONT color='dimgray'>;</FONT>
<FONT color='gray'>271| </FONT> <FONT color='darkblue'><B>var</B></FONT> content<FONT color='dimgray'>;</FONT>
<FONT color='gray'>272| </FONT> <FONT color='darkblue'><B>if</B></FONT><FONT color='dimgray'>(</FONT><FONT color='dimgray'>!</FONT>_got_eot<FONT color='dimgray'>)</FONT>
<FONT color='gray'>273| </FONT> <FONT color='darkblue'><B>while</B></FONT><FONT color='dimgray'>(</FONT><FONT color='dimgray'>!</FONT>_in<FONT color='dimgray'>.</FONT>eof<FONT color='dimgray'>)</FONT>
<FONT color='gray'>274| </FONT> <FONT color='dimgray'>{</FONT>
<FONT color='gray'>275| </FONT> <FONT color='darkblue'><B>var</B></FONT> v <FONT color='dimgray'>=</FONT> _in<FONT color='dimgray'>.</FONT><FONT color='purple'>get</FONT><FONT color='dimgray'>(</FONT><FONT color='maroon'>'<'</FONT><FONT color='dimgray'>)</FONT><FONT color='dimgray'>;</FONT>
<FONT color='gray'>276| </FONT> <FONT color='green'>//out.printf("DEBUG: (%s) content (%s)\n",name,content); </FONT>
<FONT color='gray'>277| </FONT> <FONT color='darkblue'><B>if</B></FONT><FONT color='dimgray'>(</FONT>v<FONT color='dimgray'>)</FONT>
<FONT color='gray'>278| </FONT> <FONT color='dimgray'>{</FONT>
<FONT color='gray'>279| </FONT> <FONT color='darkblue'><B>if</B></FONT><FONT color='dimgray'>(</FONT><FONT color='dimgray'>!</FONT>content<FONT color='dimgray'>)</FONT> <FONT color='green'>// make it string</FONT>
<FONT color='gray'>280| </FONT> content <FONT color='dimgray'>=</FONT> <FONT color='purple'>unescape</FONT><FONT color='dimgray'>(</FONT>v<FONT color='dimgray'>)</FONT><FONT color='dimgray'>;</FONT>
<FONT color='gray'>281| </FONT> <FONT color='darkblue'><B>else</B></FONT> <FONT color='green'>// array</FONT>
<FONT color='gray'>282| </FONT> content<FONT color='dimgray'>.</FONT><FONT color='purple'>push</FONT><FONT color='dimgray'>(</FONT><FONT color='purple'>unescape</FONT><FONT color='dimgray'>(</FONT>v<FONT color='dimgray'>)</FONT><FONT color='dimgray'>)</FONT><FONT color='dimgray'>;</FONT>
<FONT color='gray'>283| </FONT> <FONT color='dimgray'>}</FONT>
<FONT color='gray'>284| </FONT> v <FONT color='dimgray'>=</FONT> <FONT color='purple'>compile_tag</FONT><FONT color='dimgray'>(</FONT>name<FONT color='dimgray'>)</FONT><FONT color='dimgray'>;</FONT>
<FONT color='gray'>285| </FONT> <FONT color='darkblue'><B>if</B></FONT><FONT color='dimgray'>(</FONT>v<FONT color='dimgray'>)</FONT> <FONT color='dimgray'>{</FONT>
<FONT color='gray'>286| </FONT> <FONT color='darkblue'><B>if</B></FONT><FONT color='dimgray'>(</FONT> <FONT color='dimgray'>!</FONT><FONT color='purple'>is_array</FONT><FONT color='dimgray'>(</FONT>content<FONT color='dimgray'>)</FONT> <FONT color='dimgray'>)</FONT> content <FONT color='dimgray'>=</FONT> content? <FONT color='darkblue'><B>new</B></FONT> <FONT color='purple'>array</FONT><FONT color='dimgray'>(</FONT>content<FONT color='dimgray'>)</FONT> <FONT color='dimgray'>:</FONT> <FONT color='darkblue'><B>new</B></FONT> <FONT color='purple'>array</FONT><FONT color='dimgray'>(</FONT><FONT color='dimgray'>)</FONT><FONT color='dimgray'>;</FONT>
<FONT color='gray'>287| </FONT> content<FONT color='dimgray'>.</FONT><FONT color='purple'>push</FONT><FONT color='dimgray'>(</FONT>v<FONT color='dimgray'>)</FONT><FONT color='dimgray'>;</FONT>
<FONT color='gray'>288| </FONT> <FONT color='dimgray'>}</FONT>
<FONT color='gray'>289| </FONT> <FONT color='darkblue'><B>else</B></FONT> <FONT color='green'>// this was tail of this tag</FONT>
<FONT color='gray'>290| </FONT> <FONT color='darkblue'><B>break</B></FONT><FONT color='dimgray'>;</FONT>
<FONT color='gray'>291| </FONT> <FONT color='dimgray'>}</FONT>
<FONT color='gray'>292| </FONT> <FONT color='darkblue'><B>return</B></FONT> <FONT color='purple'>is_array</FONT><FONT color='dimgray'>(</FONT>content<FONT color='dimgray'>)</FONT>?
<FONT color='gray'>293| </FONT> <FONT color='darkblue'><B>new</B></FONT> <FONT color='purple'>element</FONT><FONT color='dimgray'>(</FONT>name<FONT color='dimgray'>,</FONT>atts_map<FONT color='dimgray'>,</FONT>content<FONT color='dimgray'>)</FONT><FONT color='dimgray'>:</FONT>
<FONT color='gray'>294| </FONT> <FONT color='darkblue'><B>new</B></FONT> <FONT color='purple'>simple_element</FONT><FONT color='dimgray'>(</FONT>name<FONT color='dimgray'>,</FONT>atts_map<FONT color='dimgray'>,</FONT>content<FONT color='dimgray'>)</FONT><FONT color='dimgray'>;</FONT>
<FONT color='gray'>295| </FONT> <FONT color='dimgray'>}</FONT>
<FONT color='gray'>296| </FONT> <FONT color='dimgray'>}</FONT>
<FONT color='gray'>297| </FONT> <FONT color='dimgray'>}</FONT>
<FONT color='gray'>298| </FONT> <FONT color='darkblue'><B>function</B></FONT> <FONT color='purple'>parse</FONT><FONT color='dimgray'>(</FONT>in_stream<FONT color='dimgray'>)</FONT>
<FONT color='gray'>299| </FONT> <FONT color='dimgray'>{</FONT>
<FONT color='gray'>300| </FONT> _in <FONT color='dimgray'>=</FONT> in_stream<FONT color='dimgray'>;</FONT>
<FONT color='gray'>301| </FONT> <FONT color='darkblue'><B>var</B></FONT> r <FONT color='dimgray'>=</FONT> <FONT color='darkblue'><B>null</B></FONT><FONT color='dimgray'>;</FONT>
<FONT color='gray'>302| </FONT> <FONT color='darkblue'><B>try</B></FONT> <FONT color='dimgray'>{</FONT>
<FONT color='gray'>303| </FONT> <FONT color='darkblue'><B>do</B></FONT> <FONT color='dimgray'>{</FONT>
<FONT color='gray'>304| </FONT> <FONT color='darkblue'><B>if</B></FONT><FONT color='dimgray'>(</FONT> <FONT color='purple'>typeof</FONT><FONT color='dimgray'>(</FONT>_in<FONT color='dimgray'>.</FONT><FONT color='purple'>get</FONT><FONT color='dimgray'>(</FONT><FONT color='maroon'>'<'</FONT><FONT color='dimgray'>)</FONT><FONT color='dimgray'>)</FONT> <FONT color='dimgray'>==</FONT> type<FONT color='dimgray'>::</FONT>NULL<FONT color='dimgray'>)</FONT> <FONT color='darkblue'><B>break</B></FONT><FONT color='dimgray'>;</FONT>
<FONT color='gray'>305| </FONT> r <FONT color='dimgray'>=</FONT> <FONT color='purple'>compile_tag</FONT><FONT color='dimgray'>(</FONT><FONT color='maroon'>"."</FONT><FONT color='dimgray'>)</FONT><FONT color='dimgray'>;</FONT>
<FONT color='gray'>306| </FONT> <FONT color='green'>//skiping all pi's and doctypes</FONT>
<FONT color='gray'>307| </FONT> <FONT color='dimgray'>}</FONT> <FONT color='darkblue'><B>while</B></FONT><FONT color='dimgray'>(</FONT> <FONT color='dimgray'>!</FONT><FONT color='purple'></FONT><FONT color='dimgray'>(</FONT>r instanceof simple_element<FONT color='dimgray'>)</FONT> <FONT color='dimgray'>)</FONT><FONT color='dimgray'>;</FONT> <FONT color='green'>// or element</FONT>
<FONT color='gray'>308| </FONT> <FONT color='dimgray'>}</FONT> <FONT color='darkblue'><B>catch</B></FONT> <FONT color='purple'></FONT><FONT color='dimgray'>(</FONT>e<FONT color='dimgray'>)</FONT> <FONT color='dimgray'>{</FONT> std<FONT color='dimgray'>::</FONT>out<FONT color='dimgray'>.</FONT><FONT color='purple'>printf</FONT><FONT color='dimgray'>(</FONT><FONT color='maroon'>"ERROR:%s"</FONT><FONT color='dimgray'>,</FONT>e<FONT color='dimgray'>)</FONT><FONT color='dimgray'>;</FONT> <FONT color='dimgray'>}</FONT>
<FONT color='gray'>309| </FONT> _in<FONT color='dimgray'>.</FONT><FONT color='purple'>close</FONT><FONT color='dimgray'>(</FONT><FONT color='dimgray'>)</FONT><FONT color='dimgray'>;</FONT>
<FONT color='gray'>310| </FONT> <FONT color='darkblue'><B>return</B></FONT> r<FONT color='dimgray'>;</FONT>
<FONT color='gray'>311| </FONT> <FONT color='dimgray'>}</FONT>
<FONT color='gray'>312| </FONT><FONT color='dimgray'>}</FONT>
<FONT color='gray'>313| </FONT>
</PRE></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -