xmldump
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 | // $Id: xmldump.pp,v 1.4 2005/02/14 17:13:18 peter Exp $ {$MODE objfpc} {$H+} program xmldump; uses sysutils, DOM, xmlread; const NodeNames: array[ELEMENT_NODE..NOTATION_NODE] of String = ( 'Element', 'Attribute', 'Text', 'CDATA section', 'Entity reference', 'Entity', 'Processing instruction', 'Comment', 'Document', 'Document type', 'Document fragment', 'Notation' ); procedure DumpNode(node: TDOMNode; spc: String); var i: Integer; attr: TDOMNode; begin Write(spc, NodeNames[node.NodeType]); if Copy(node.NodeName, 1, 1) <> '#' then Write(' "', node.NodeName, '"'); if node.NodeValue <> '' then Write(' "', node.NodeValue, '"'); if (node.Attributes <> nil) and (node.Attributes.Length > 0) then begin Write(','); for i := 0 to node.Attributes.Length - 1 do begin attr := node.Attributes.Item[i]; Write(' ', attr.NodeName, ' = "', attr.NodeValue, '"'); end; end; WriteLn; if node.FirstChild <> nil then DumpNode(node.FirstChild, spc + ' '); if node.NextSibling <> nil then DumpNode(node.NextSibling, spc); end; var xml: TXMLDocument; begin if ParamCount <> 1 then begin WriteLn('xmldump <xml or dtd file>'); exit; end; if UpCase(ExtractFileExt(ParamStr(1))) = '.DTD' then ReadDTDFile(xml,ParamStr(1)) else ReadXMLFile(xml,ParamStr(1)); WriteLn('Successfully parsed the document. Structure:'); WriteLn; if Assigned(xml.DocType) then begin WriteLn('DocType: "', xml.DocType.Name, '"'); WriteLn; end; DumpNode(xml, '| '); xml.Free; end. { $Log: xmldump.pp,v $ Revision 1.4 2005/02/14 17:13:18 peter * truncate log } |
¿Has encontrado algún error? ¿Tienes la solución? Dejame tu correción ;-)
Antes de comentar: Gran parte de los ejercicios propuestos no tienen librerías debido a que Wordpress las eliminó al verlas como etiquetas HTML. Si sabes/tienes/conoces las librerías que hacen falta, déjalo en los comentarios. Y lo mas importante: Todos los ejemplos fueron realizados por personas con únicamente conocimiento básico del lenguaje, no de programación.
Otro punto importante: Si vas a sugerir un segmento de código en algún lenguaje debes hacerlo así:
- Si es lenguaje C <code lang="c">Código en C</code>
- Si es lenguaje Pascal <code lang="pascal">Aquí dentro el código de Pascal</code>.
De esta manera el código coloreas el código.
Otro punto importante para muchos que crees que te he ignorado: Todos los comentarios los reviso y en su debido momento los apruebo, pero ojo con el con lo siguiente:Me reservo el derecho de alterar, publicar o no los comentarios así como también cambiar mis condiciones en el momento que yo lo requiera.
¿Si estas de acuerdo? Adelante! que ya te he quitado bastante tiempo leyendo esta basura :)