Advertisement
Guest User

Untitled

a guest
Feb 25th, 2013
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // NSXMLParser
  2.  
  3. - (void) tratarXMLTest: (NSString *) xml
  4. {
  5.     NSData* xmlData = [[NSData alloc] initWithData:[xml dataUsingEncoding:NSUTF8StringEncoding]];
  6.     NSXMLParser *XMLReader = [[NSXMLParser alloc] initWithData: xmlData];
  7.     [XMLReader setDelegate: self];
  8.     [XMLReader parse];
  9.     NSLog(@"Número de líneas %d - Número de columnas %d - System id %@", [XMLReader lineNumber],[XMLReader columnNumber], [XMLReader systemID]);
  10.     [XMLReader abortParsing];
  11. }
  12.  
  13. - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict
  14. {
  15.     NSLog(@"didStartElement: %@", elementName);
  16.     NSLog(@"namespaceURI: %@", namespaceURI);
  17.     NSLog(@"qualifiedName: %@", qualifiedName);
  18.     NSLog(@"attributes: %@", attributeDict);
  19. }
  20.  
  21. // XML File
  22. <object>
  23. <piloto>
  24. <id>1</id>
  25. <alias>juan</alias>
  26. <email>jps@solu.pro</email>
  27. <fechaAlta>2013-02-19 16:23:33</fechaAlta>
  28. <nombre>Juan</nombre>
  29. <apellido1>Prada</apellido1>
  30. <apellido2></apellido2>
  31. <tlf_fijo>928112233</tlf_fijo>
  32. <tlf_movil>6667788899</tlf_movil>
  33. <facebook></facebook>
  34. </piloto>
  35. </object>
  36.  
  37. // NSLog prompted
  38. 2013-02-25 10:33:36.742 GeoRuta[1624:907] didStartElement: object
  39. 2013-02-25 10:33:36.743 GeoRuta[1624:907] namespaceURI: (null)
  40. 2013-02-25 10:33:36.744 GeoRuta[1624:907] qualifiedName: (null)
  41. 2013-02-25 10:33:36.745 GeoRuta[1624:907] attributes: {
  42. }
  43. 2013-02-25 10:33:36.746 GeoRuta[1624:907] didStartElement: piloto
  44. 2013-02-25 10:33:36.746 GeoRuta[1624:907] namespaceURI: (null)
  45. 2013-02-25 10:33:36.747 GeoRuta[1624:907] qualifiedName: (null)
  46. 2013-02-25 10:33:36.748 GeoRuta[1624:907] attributes: {
  47. }
  48. 2013-02-25 10:33:36.749 GeoRuta[1624:907] didStartElement: id
  49. 2013-02-25 10:33:36.750 GeoRuta[1624:907] namespaceURI: (null)
  50. 2013-02-25 10:33:36.751 GeoRuta[1624:907] qualifiedName: (null)
  51. 2013-02-25 10:33:36.751 GeoRuta[1624:907] attributes: {
  52. }
  53. 2013-02-25 10:33:36.752 GeoRuta[1624:907] didStartElement: alias
  54. 2013-02-25 10:33:36.753 GeoRuta[1624:907] namespaceURI: (null)
  55. 2013-02-25 10:33:36.754 GeoRuta[1624:907] qualifiedName: (null)
  56. 2013-02-25 10:33:36.755 GeoRuta[1624:907] attributes: {
  57. }
  58. 2013-02-25 10:33:36.756 GeoRuta[1624:907] didStartElement: email
  59. 2013-02-25 10:33:36.757 GeoRuta[1624:907] namespaceURI: (null)
  60. 2013-02-25 10:33:36.757 GeoRuta[1624:907] qualifiedName: (null)
  61. 2013-02-25 10:33:36.758 GeoRuta[1624:907] attributes: {
  62. }
  63. 2013-02-25 10:33:36.759 GeoRuta[1624:907] didStartElement: fechaAlta
  64. 2013-02-25 10:33:36.760 GeoRuta[1624:907] namespaceURI: (null)
  65. 2013-02-25 10:33:36.761 GeoRuta[1624:907] qualifiedName: (null)
  66. 2013-02-25 10:33:36.762 GeoRuta[1624:907] attributes: {
  67. }
  68. 2013-02-25 10:33:36.763 GeoRuta[1624:907] didStartElement: nombre
  69. 2013-02-25 10:33:36.763 GeoRuta[1624:907] namespaceURI: (null)
  70. 2013-02-25 10:33:36.764 GeoRuta[1624:907] qualifiedName: (null)
  71. 2013-02-25 10:33:36.765 GeoRuta[1624:907] attributes: {
  72. }
  73. 2013-02-25 10:33:36.766 GeoRuta[1624:907] didStartElement: apellido1
  74. 2013-02-25 10:33:36.767 GeoRuta[1624:907] namespaceURI: (null)
  75. 2013-02-25 10:33:36.768 GeoRuta[1624:907] qualifiedName: (null)
  76. 2013-02-25 10:33:36.768 GeoRuta[1624:907] attributes: {
  77. }
  78. 2013-02-25 10:33:36.769 GeoRuta[1624:907] didStartElement: apellido2
  79. 2013-02-25 10:33:36.770 GeoRuta[1624:907] namespaceURI: (null)
  80. 2013-02-25 10:33:36.771 GeoRuta[1624:907] qualifiedName: (null)
  81. 2013-02-25 10:33:36.772 GeoRuta[1624:907] attributes: {
  82. }
  83. 2013-02-25 10:33:36.773 GeoRuta[1624:907] didStartElement: tlf_fijo
  84. 2013-02-25 10:33:36.773 GeoRuta[1624:907] namespaceURI: (null)
  85. 2013-02-25 10:33:36.774 GeoRuta[1624:907] qualifiedName: (null)
  86. 2013-02-25 10:33:36.775 GeoRuta[1624:907] attributes: {
  87. }
  88. 2013-02-25 10:33:36.776 GeoRuta[1624:907] didStartElement: tlf_movil
  89. 2013-02-25 10:33:36.777 GeoRuta[1624:907] namespaceURI: (null)
  90. 2013-02-25 10:33:36.778 GeoRuta[1624:907] qualifiedName: (null)
  91. 2013-02-25 10:33:36.778 GeoRuta[1624:907] attributes: {
  92. }
  93. 2013-02-25 10:33:36.779 GeoRuta[1624:907] didStartElement: facebook
  94. 2013-02-25 10:33:36.780 GeoRuta[1624:907] namespaceURI: (null)
  95. 2013-02-25 10:33:36.781 GeoRuta[1624:907] qualifiedName: (null)
  96. 2013-02-25 10:33:36.782 GeoRuta[1624:907] attributes: {
  97. }
  98. 2013-02-25 10:33:36.783 GeoRuta[1624:907] Número de líneas 14 - Número de columnas 10 - System id (null)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement