How to retrieve version and encoding info from SAX parser

I want to have access to the version and encoding info in a parsed XML document (when using SAX2). Who knows how this works?
If not possible with SAX2, what other solutions are there?
Second question: how to retrieve comments in XML files?
Thanks in advance!

thanks for answering, but ...
LexicalHandler is fine for retrieving the comments,
but does not give me the encoding (specified by
encoding="UTF-8") and version (specified by
version="1.0").
I am feeding my parser with a byte stream, the parser
resolves the correct encoding and i want to have
access to this value!!hi , It is unlikely that you will get the encoding and version . This is being addressed by the DOM level3
, see
http://www-106.ibm.com/developerworks/xml/library/x-dom3.html?dwzone=xml .

Similar Messages

  • How to get a specific tag value from SAX parser

    I am using the SAX method to parse my xml file.
    My Question is how to get the returning characters parsed after calling?
    esp the value of <body> tag?
    Here is my xml file, and i want to get the parsed <body> value after call sax parser.
    <?xml version="1.0" encoding="UTF-8"?>
    <article>
    <content>
    <title>floraaaaa</title>
    <date>2004-03-19</date>
    <body>
    Details of an article, and i want to get the article details
    </body>
    </content>
    </article>

    here is the parser code I am using:
    import java.io.*;
    import org.apache.xerces.parsers.SAXParser;
    import org.xml.sax.Attributes;
    import org.xml.sax.ContentHandler;
    import org.xml.sax.ErrorHandler;
    import org.xml.sax.Locator;
    import org.xml.sax.SAXException;
    import org.xml.sax.SAXParseException;
    import org.xml.sax.XMLReader;
    import org.xml.sax.helpers.XMLReaderFactory;
    public class test2 {
         public String m_xmlDetail;
         public void readDetail(String url) {
              System.out.println("Parsing XML File: " + url + "\n\n");
              try {
                   XMLReader parser = new SAXParser();
                   ContentHandler contentHandler = new MyContentHandler();
                   parser.setContentHandler(contentHandler);
                   parser.parse(url);
              } //try ends here
              catch (IOException e) {
                   System.out.println("Error reading URI: " + e.getMessage());
              } //catch ends here
              catch (SAXException e) {
                   System.out.println("Error in parsing: " + e.getMessage());
              } //catch ends here
         } //function
    }//close class
    public class MyContentHandler implements ContentHandler {
         private Locator locator;
         //public String m_bodyDetail=new String();
         public void setDocumentLocator(Locator locator) {
              System.out.println(" * setDocumentLocator() called");
              this.locator = locator;
         public void startDocument() throws SAXException {
              System.out.println("Parsing begins...");
         public void endDocument() throws SAXException {
              System.out.println("...Parsing ends.");
         public void processingInstruction(String target, String data)throws SAXException {
              System.out.println("PI: Target:" + target + " and Data:" + data);
         public void startPrefixMapping(String prefix, String uri) {
              System.out.println("Mapping starts for prefix " + prefix + " mapped to URI " + uri);
         public void endPrefixMapping(String prefix) {
              System.out.println("Mapping ends for prefix " + prefix);
         public void startElement(String namespaceURI, String localName,String rawName, Attributes atts)throws SAXException {
              System.out.print("startElement: " + localName);
              if (!namespaceURI.equals("")) {
                   System.out.println(" in namespace " + namespaceURI + " (" + rawName + ")");
              else {
                   System.out.println(" has no associated namespace");
              for (int i=0; i<atts.getLength(); i++)
                   System.out.println(" Attribute: " + atts.getLocalName(i) +"=" + atts.getValue(i));
         public void endElement(String namespaceURI, String localName, String rawName) throws SAXException {
              System.out.println("endElement: " + localName + "\n");
         public void characters(char[] ch, int start, int end) throws SAXException {
              String s = new String(ch, start, end);
              System.out.println("characters: " + s);
         public void ignorableWhitespace(char[] ch, int start, int end)throws SAXException {
              String s = new String(ch, start, end);
              System.out.println("ignorableWhitespace: [" + s + "]");
         public void skippedEntity(String name) throws SAXException {
              System.out.println("Skipping entity " + name);
    } //close class

  • How to get contacts and calendar info from my old palm files

    I used to use a Palm Tungsten T3. I no longer have it but until recently I still used the Palm Desktop. My computer "died" and I was able to copy all the Palm files of of it but now I have no idea how to get the contact and calendar(less important than contacts) info in some form I can use. I do not currently have any Palm software installed on my computer. I have Microsoft Windows XP on my computer now and use Outlook or Outlook Express. Does anyone have any advice for me. Thanks in advance.
    Post relates to: Tungsten T3

    I'm having the same problem.  Desktop 4.1.4 on old PC.  New PC with Win 7.   Loaded 6.2 and when I went to Import 6.2 is looking for .aba files.  Old PC has all .dat files.  How do I import or transfer addresses and other contact info to new PC??  Thanks.

  • How to retrieve email and contacts data from time machine from a different computer

    My iMac hard disc has died and though I have everything backed up on Time Machine I am finding it difficult to access my Contacts (not on iCloud) and emails from my laptop. 
    I understand that they are to be found on the Time Machine backup in library/applicationsupport/addressbook and /Library/Mail/V2, but these files appear to be hidden.
    From my reading it has been suggested that I use the utility Terminal, but I don’t know where to start with this – any guidance would be most welcome

    Please visit Pondini's Time Machine FAQ for help with all things Time Machine.

  • HT201303 I have been lent a ipad and really hate it how do I delete all my info from it before giving it back.

    I have been lent a ipad and really hate it how do I delete all my info from it before giving it back.

    Tap on your id in Settings > Store (Settings > iTunes & App Store if it's on iOS 6) and logout of your account, and then do Settings > General > Reset > Erase All Content And Settings

  • How do I send my BMP info from logic to pedals and keys?

    How do I send my BMP info from logic to pedals and keys?
    Is it possible to sync my logic bmp with my microkorg so that my korg automatic will sync with the BMP from logic?

    I'm not faniliar with the Micro, but logic outputs mtc and midi clock. The serttings are under project settings/synchronization. You'll have to set the Micro to external sync and be sending midi info from your computer to the Micro. Then if you hit play or record in Logic, the micro will chase it.

  • How do I get the iCloud to save and sync and upload info from both the devices on my account. Right now I can only do one

    How do I get the iCloud to save and sync and upload info from both the devices on my account. Right now I can only do one

    You must put each device on the Verizon cloud.
    Not both lines on one.
    Go and set up a my Verizon account for the second line and you will have Verizon cloud service on that line.
    Oh the term "icloud" is a trademark of Apple Inc. Verizon is not Apple.
    Good Luck

  • How to fine the oracle version and bit info?

    I just want to find out the
    Oracle version
    Bit info (32 or 64....)
    and other system configuration about oracle
    Please help

    Duplicate post:
    how to fine the oracle version and bit info?

  • How to retrieve start and end date values from sharepoint 2013

    Hi,
    How to retrieve start and end date values from new event form of calendar in SharePoint foundation2013
    Thanks
    Gowri Balaguru

    Hi Srini
    Yes i need to have parallel flow for both and in the cube where my reporting will be on monthly basis i need to read these 2 master data and get the required attributes ( considering last/first day of that month as per the requirement).......but i am just wondering this is common scenario....while there are so many threads written for populating 0employee from 0person......don't they have such requirement.....
    Thanks
    Tripple k

  • I lost my logic 8 pro serial number. I can't find the booklet that comes with the serial number. How can retrieve this? I upgraded from logic pro 7. I changed hard drives and now it keeps asking for the serial number. But I can't find it. Where can I requ

    I lost my logic 8 pro serial number. I can't find the booklet that comes with the serial number. How can retrieve this? I upgraded from logic pro 7. I changed hard drives and now it keeps asking for the serial number. But I can't find it. Where can I request it? Thanks!

    If you still have the receipt or other proof of purchase, you can ask Apple to send you the serial. Otherwise, bad luck mate.. Good news is, you can now buy Logic Pro 9 from App Store for just 199 USD

  • My iPhone 5S drowned in a rainstorm. How can I retrieve contacts and text messages from iCloud backup onto my iPad mini?

    My iPhone 5S drowned in a rainstorm. How can I retrieve contacts and text messages from iCloud backup onto my iPad mini? There are some contacts on the iPad already but nowhere near all of them. I need to re-enter the contacts manually into an iPhone 4 as it does not support iOS 8.

    Let me get this straight.....You lost your phone.  You never backed it up, either to your computer or to a cloud service.
    How in the world would you expect to get data back?

  • All of a sudden when downloading free apps i ger error code that the security code on my cc is invalid.  I havnt changed anything! How do i check my billing info from ipad and why am i getting message in first place?

    How do i check my billing info from ipad? All of a sudden im getting error messages that sec code on my cc is invalid when i go to download FREE apps? I havnt changed a thing on my end to warrant this error message

    Same thing happened to me with my peruvian credit card in the peruvian app store, I want to buy an app, but it says that my credit card is "not supported in the Peruvian app store"

  • How can i remove credit card info from apple id?

    How can i remove credit crad info from my apple id?

    I tried to enter it as "none" but it didnt work. It keeps saying i need a card number and all that. But then, i clicked "same as shipping information" and just entered my name and all the adress stuff, put my credit card number as 0 and my security code as 0, put in a random date and clicked save.
    -Just a tip for anyone else who couldnt figure it out like me

  • How can I transfer all my info from my old mac to a new one?

    how can I transfer all my info from my old macbook to my mac mini?
    My Mac mini chash about one month ago and I got it back from apple, I didnt have a time michine back up for this one but in my old mac I have almost all my files, so I want to transfer all the data to the Mac mini with no problem

    You can use migration assitant which is located in the Utility Folder under Applications. The compters can be connected via ethernet, fire wire, or wifi. My recommendation is not to use wifi.
    You run migration assistant on both machines and you can choose to transfer everything or just data.
    Another way is to use migration assistant to restore from a time machine backup.

  • Using family sharing, how does one view and download songs from a family member's collection in itunes?

    Using family sharing, how does one view and download songs from a family member's collection in itunes?

    When you click on your device you are presented with the pages
    Summary
    Info
    Apps
    Tones
    Music
    Movies
    TV shows
    Books
    Photos
    To remove Audiobooks depending on the type of Audiobook ie a series of mp3 files you will find under music and probably have to deselect the album name to remove it. I don't have any of these as I download from Audible or I use Audiobook Builder to stictch together mp3 files into m4b files. To find these Click on Books you will immediately see a section for books (in reality ebooks). Scroll down past that and you will see Audiobooks where you can select and deselect. Deselect the required Audiobooks and Click Sync

Maybe you are looking for

  • Error when checking for layout in sap system.

    Hi,    We have downloaded the Adobe Life Cycle Designer 8.0 from service.sap.com.As in our system we have already installed the SAP GUI ,we only run the ALDsetup. exe to install the Adobe Life Cycle Designer 8.0 .When we checked in our backend SAP sy

  • Bug with number of new emails?

    The "new mail" count on the home screen is always 2 times as high as the real number of new emails. The badge shows 4 when I have 2 new emails, 6 when I have three etc. I've restored the iPhone, no luck. I have Gmail configured on Imap. Would you kno

  • How do I apply 8.0.1 Patch?

    Anyone know how to apply the 8.0.1 patch for Linux? There are no instructions and it is not an installer like the windows patch. This is very frustrating and after running Coldfusion since verion 4.5 on Linux, for the first time I don't know how to a

  • All my Album artwork has gone missing and I get error code (-609)??

    All my Album artwork has gone missing and I get error code (-609)??

  • Amex application "In progress" status. Approved?

    Hi, my credit is only 5 months old. I applied for PRG and Delta cards on Wednesday evening. As I don't currently have FICO generated, Amex requested copy of my stab. I complied, and today the status changed from "Submit additional documentation" to "