Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 7th, 2012  |  syntax: None  |  size: 1.09 KB  |  hits: 8  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Is this XML valid, and how to create it with TXMLDocument
  2. <?xml version="1.0"?>
  3. <p class="leaders">
  4.     Todd
  5.     <span class="leader-type">.</span>
  6.     R
  7.     <span class="leader-type">.</span>
  8.     Colas
  9. </p>
  10.        
  11. p
  12. |_ attributes
  13. | |_ "class"="leaders"
  14. |
  15. |_ children
  16.   |_ #text "Todd"
  17.   |
  18.   |_ span
  19.   | |_ attributes
  20.   | | |_ "class"="leader-type"
  21.   | |
  22.   | |_ children
  23.   |   |_ #text "."
  24.   |
  25.   |_ #text "R"
  26.   |
  27.   |_ span
  28.   | |_ attributes
  29.   | | |_ "class"="leader-type"
  30.   | |
  31.   | |_ children
  32.   |   |_ #text "."
  33.   |
  34.   |_ #text "Colas"
  35.        
  36. Doc.Active := False;
  37. Doc.Active := True;
  38.  
  39. Node := Doc.AddChild('p');
  40. Node.Attributes['class'] := 'leaders';
  41.  
  42. Child := Doc.CreateNode('Todd', ntText);
  43. Node.ChildNodes.Add(Child);
  44.  
  45. Child := Node.AddChild('span');
  46. Child.Attributes['class'] := 'leader-type';
  47. Child.Text := '.';
  48.  
  49. Child := Doc.CreateNode('R', ntText);
  50. Node.ChildNodes.Add(Child);
  51.  
  52. Child := Node.AddChild('span');
  53. Child.Attributes['class'] := 'leader-type';
  54. Child.Text := '.';
  55.  
  56. Child := Doc.CreateNode('Colas', ntText);
  57. Node.ChildNodes.Add(Child);
  58.  
  59. Doc.SaveTo...(...); // generate the XML to your preferred output