Hi,

according to what have found in the SAXHandler and XMLDOMParser class, you 
should use SAXHandler>>characters: method to get the information inside a 
marker.

Information inside a marker is consider as an XMLString that is created after a 
call to XMLDOMParser>>characters:.


I hope I helped you with your question. =)



--------------
Brice Govin
PhD student in RMoD research team at INRIA Lille
Software Engineer at THALES AIR SYSTEMS Rungis
ENSTA-Bretagne ENSI2014

22 Avenue du General Leclerc 92340 BOURG-LA-REINE



________________________________
De : stepharo [via Smalltalk] <ml-node+[hidden 
email]</user/SendEmail.jtp?type=node&node=4884099&i=0>>
Envoyé : vendredi 11 mars 2016 13:37
À : Brice GOVIN
Objet : How to access XML tag name?

Hi

Yesterday I started to hack a smart SAX handler. The idea is that I want
to just specify the tags
I want to visit and the SAX handler should invoke (generated) visit
methods. Like that I can easily
get visitors on XML domain.

Here is an example of what I did.

     | h |
     h := SmartSAXHandler new
                 visitor: (MyFilmVisitor new visitTags: #(FILM ROLE));
                 on: FileSystem workingDirectory / 'FILMS.XML'.
     h parseDocument.
     ^ h



SmartSAXHAndler >> startElement: aQualifiedName attributes: aDictionary

     (visitor shouldVisit: aQualifiedName)
         ifTrue: [
                 visitor
                     perform: (visitor createdVisitSelector: aQualifiedName)
                     with: aQualifiedName
                     with: aDictionary
         ]


Object subclass: #GenericTagSAXVisitor
     instanceVariableNames: 'visitTag visitTags'
     classVariableNames: ''
     category: 'SmartXMLHandler'


GenericTagSAXVisitor>>visitTags: aCollection
     "set the tags that will lead to a call to a visitTag:with: method
in the visitor"

     visitTags := aCollection collect: [ :each | each asLowercase ].
     self createVisitMethods.

and in a subclass the visit* methods automatically generated


Now I could not get when I have a <TITRE>Vertigo</TITRE> where I can get
the Vertigo information.
I redefined several methods of SAXhandler but without success.


<?xml version="1.0" encoding="iso-8859-1"?>
<FILMS>
   <FILM annee="1958">
     <TITRE>Vertigo</TITRE>
     <GENRE>Drame</GENRE>
     <PAYS>USA</PAYS>
     <MES idref="3"/>
     <ROLES>
       <ROLE>
         <PRENOM>James</PRENOM>
         <NOM>Stewart</NOM>
         <INTITULE>John Ferguson</INTITULE>
       </ROLE>
       <ROLE>
         <PRENOM>Kim</PRENOM>
         <NOM>Novak</NOM>
         <INTITULE>Madeleine Elster</INTITULE>
       </ROLE>
     </ROLES>
     <RESUME>Scottie Ferguson, ancien inspecteur de police, est sujet
au vertige depuis qu'il a vu mourir son
  collegue. Elster, son ami, le charge de surveiller sa femme,
Madeleine, ayant des tendances
  suicidaires. Amoureux de la jeune femme Scottie ne remarque pas le
piege qui se trame autour
  de lui et dont il va etre la victime... </RESUME>
   </FILM>



________________________________
If you reply to this email, your message will be added to the discussion below:
http://forum.world.st/How-to-access-XML-tag-name-tp4884065.html
To unsubscribe from Pharo Smalltalk Users, click here.
NAML<http://forum.world.st/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>

________________________________
View this message in context: RE: How to access XML tag 
name?<http://forum.world.st/How-to-access-XML-tag-name-tp4884065p4884099.html>
Sent from the Pharo Smalltalk Users mailing list 
archive<http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html> at 
Nabble.com.

Reply via email to