How do the itl and xml files work

Due to some problems I have been having (now solved) I have been trying to get to grips with how these 2 files work.
I now have a library of 37000 some songs in q:\itunes\itunes music and everything is working fine.
However when I look in the xml file some song pointers are still to my documents\my music\itunes yet itunes still finds them. How?
Does itunes look for the location set in edit>preferences>advanced>itunes music folder location first and then check the xml file address if it cannot find them there?
Also if the songs are in the correct location anyway why is the xml file pointer looking at my documents.
Does anyone know if this is abnormal? Can anyone explain the logic to me please 'cos to me it ain't logical!!
Regards,
Andy.

I think iTunes must have got in a muddle as a result of the way you transfered your files to the external drive.
It is important to realise that the iTunes Music folder location as designated in your preferences tells iTunes where to add music in the future. It is quite possible to get in a situation where iTunes looks there for newly added music, but continues to look in the old location for previously added files.
If the xml file tells you it is accessing files in iTunes iTunes Music on your c: drive, then that is it is telling the truth. However these files are not longer in THE itunes Muisc folder , that is to say the one set in your preferences. All very confusing I am afraid.
If your file locations get corrected when you play a track, there is something you could try.
First close iTunes and make a copy of your xml and itl files in case you don't like what happens.
Now open iTunes and go to you music view and select your entire library with select all.
Right click in the selection and choose Get Info. Say yes to multimle edits.
When you see the multipe edit Get Into screen, simply exit with OK, do nothing else. This will force iTunes to reread all your tags which may take a while if your library is large. If I geussed right, it will also update the file locations. Although I have used multiple get into in this way to correct tag into I haven't tried it to correct paths so this is just a guess - it could only possibly work for files that are in the designated iTunes Music folder in the proper place, but iTunes is still pointing to an old loaction where the files no longer exist.

Similar Messages

  • How read the PDF and XML files after Unzipping the folder

    Hi Gurus,
    I have a zipped folder and i this two types of files .XML and .PDF files.
    I am able to unzip the folder and reading the .XML files, unable to read the PDF files.
    I want to send this PDF file to the target as it is.
    Please help me.
    Regards
    Sreeni

    Hi,
    Hi ,
    Plse see the below thread
    PI 7.1 : Taking a input PDF file and mapping it to a hexBinary attribute
    It will help you.
    You can write custom adapter modules:
    Java Mappingh;
    SAP Conversion agent:
    http://www.riyaz.net/blog/parsing-pdf-files-using-sap-conversion-agent-part-i/technology/sap/628/
    http://help.sap.com/saphelp_nw04/helpdata/en/43/4c38c4cf105f85e10000000a1553f6/content.htm

  • HT1296 so itunes deleted all my music from itunes, I still have all the original files however I unwittingly added new music after this happened which wipes the itl and xml files. I have my playlists on my iphone. how do I get itunes back to its original

    If this cant be resolved I think apple and I shall be parting ways its been a long time in the coming

    Also, what causes this, so I can avoid it in the future?

  • Forgot to backup itunes library.itl and xml files

    I backup pretty much everything. Unfortunately I forgot about the itunes library datase files, the itubes library.itl and xml files. The hard drive has been repartioned and formated, so it's gone. I do have all the music in the exact same directory structure though. Both versions are Windows 7 x64. I aslo have my iPOD.
    What I want to figure out how to do is import the database into a new install of itunes. So the music and stuff doesn't matter. It's all there in the same set of folders, with the exact same path as before. Is there any way to create the itl and xml files containing the metadata from the iPOD?
    I wouldn't even be all that bummed if I had to let my music import from the hard drive again. I just really really want to import my playlists. That would really suck if I had to type them all in manually from the iPOD. If anyone could point me int he right direction, I would really appreciate it.

    Ok googlers from the future, here is the sultion I used.
    This solution puts everything back to normal with minimal work, but it costs you however much disk space is on your ipod. I downloaded the copytrans suite off the piratebay. Then I used the ipod copy to back up my ipod. This will copy things to folders based on tags. So you have to have a second copy of your music. Once it is backed up remote the itunes library files from the top folder of the itunes library. Start itunes, and then go to import playlist. Then you select the xml file from your ipod backup. This will import the entire library into itunes. When you sync your ipod it will say iit is going to delete everything and reload it, but it doesn't. If there was stuff that was no in the library it would delete it, but there won't be because the library came from your ipod to being with. So it just copies anything to it that wasn't there, if there is anything.
    From that point, when you want to add stuff to your library/ipod, you have to put a copy of the music in the library you made. So all the music you want on your computer and your ipod will take up double space on your hard drive because you have to put a copy in the library folder. Once it is there, you just go to add folder and select your library folder. THis will make it rescan and put the new songs in the database.
    The good part of this is you don't have to do selective ipod loading. You make the selection when you copy to the library folder. So at that point you just sync your ipod making an exact copy.
    That was the best solution for me anyway, with a big library and lots of playlists. I also never use itunes. The sole purpose of having itunes is to load my ipod. My ipod I use daily though. I don't drive anywhere without it connected to my stereo. Being able to select anything in a massive music library from my head unit while driving around is seriously awesome.

  • New PC-do I need to transfer Itunes library files (itl and xml files?)

    Hi gang,
    I followed the Itunes tutorial for Windows and moved my Itunes music library to a EHD as it was filling up my laptop. I left the itl and xml library files on the laptop hard drive as instructed.
    However, this laptop is a work PC and if I change jobs I will need to download a new version of Itunes to the new PC. I know how to import the files from the EHD but my question is the following:
    1. Do I need to back up the itl and xml library files to the EHD before I give back the work PC? It seems likely since they contain info about the playlists.
    2. Once I download Itunes on the new PC would I just copy the library files onto the hard drive or can they remain on the EHD?
    It sounds like (from reading some info from Chris CA) that I need to make a copy of the Itunes folder (which includes the itl and xml files) from the laptop hard drive and put it on the EHD inside the EHD Itunes folder. Then with the new PC load a new version of Itunes and hold the shift key when launching. Then I would select the library from the EHD.
    Is that correct?
    Thanks!
    Any help would be appreciated as I cannot find anything on this in Itunes help or the forum.

    Assuming you start with a standard configuration which is:
    The iTunes folder in My music on your c: drive and all your music in the iTunes Music folder in the iTunes folder on the c: drive.
    Starting from there, with iTunes closed, you copy the iTunes folder to an external drive, this also copies the music in the iTunes Muisc folder.
    To move to a new PC, you install iTunes, then you drag your new iTunes folder to the desktop, then you replace it by copying the iTunes folder from the external drive.
    With this set up you can also run entirely on the EHD if you want to. Just start iTunes with the shift key held down, navigate to the iTunes folder on the external drive an choose iTunes Library.itl. This could be useful if you want to dake the EHD to work.
    If you are not starting from the default position I described, some adjustments would have to be made, but it would need an exact descripition of how your folders are set up at the moment.

  • I fouled up; erased library .itl and .xml files; need a little help

    I think I see what I did wrong (my issue relates to this reply post I submitted earlier today >> https://discussions.apple.com/message/16254985#16254985 but I don't think there's any need to go back and read that post to get the gist of my problem).
    So, after knocking around and reading a whole bunch of forum posts and Apple support pubs, I now know I did something dumb.
    Simply put, last night, in the course of attempting to delete from my MacBook Pro the iTunes library file residing there (the one designed to contain actual media files, i.e., music, books, podcasts, etc.), I also deleted the iTunes Library.itl and iTunes Library.xml files.  Yes, doh! is right.
    [BTW, the idea behind deleting the media library on the MBP was because my media files are -- and have been for some time -- located on an external hard drive.  So the good news is I still have all my media.  Of course, the bad news is I lost all playlists and a host of song-specific information and I'm sure a bunch of other stuff that is organized on the iTunes Library.itl file.  (Apple's helpful info sheet on the .itl and .xml files at >> http://support.apple.com/kb/HT1660)]
    So  I opened up iTunes today and there is nothing there, i.e., looks like just opened for the first time ever.  I now know that in the absence of the .itl and .xml files (which I trashed yesterday), iTunes went ahead and created new, empty versions of these files.
    HERE'S THE QUESTION: what should or can i do now to rebuild my library?  My media files still reside on my external HD and there they must stay because there isn't remotely enough room on the MBP hard drive itself.
    I'm just sort of stumped.  And skittish.  I don't want to make another dumb mistake that will make things even worse.  Any ideas?

    Hey, sorry to hear that, but good to know  that you have all your "stuff" and its just a matter of getting it all back together in the right place.  So, I have some ideas why it happened to me and maybe why this happened to you, which may be relevant later, but first I'll first explain how I got out of this jam.
    After much investigating, I finally did a search for .itl files and ended up "finding" one in the Media folder itself, specifically in the Music folder (yeah, should have done this much earlier).  Looking around, I also found the other files and folders that are supposed to be at same directory level as "iTunes Media." 
    At this point, I just moved them back to where they were supposed to be and opened iTunes and, voila, there was my stuff (albeit not quite all of it or exactly as it should be).  Then, after making sure my Media folder was properly identified in Advanced Preferences, I checked the boxes under File -> Library -> Organize Library and iTunes started doing some activity that seemed like it was reorganizing or rechecking the organization (you can see I am no expert here).
    So like I indicated, it wasn't exactly the way it was when I last used iTunes before I had the problems (e.g., various podcasts, books, etc. werent there -- so i just added them into the Library manually, i.e., File -> Add To Library, etc.).
    Anyway, I hope this helps if you haven't already fixed your problem.  If not, I might have some other ideas I came across while still searching for solution to my problem.  Best of luck.

  • Have itl and xml files on external hd am running home premium. can  no longer access files, am told this is because they were created with a newer version of itunes. also when i try to download 10.3 it wont, just says invalid drive j and for me to try aga

    i am running vista home premium on desktop and vista basic on laptop. have placed my itunes music with .itl and .xml files onto external drive connected to another desktop running vista and can no longer access music on first two mentioned comps only on the one connected to external drive. always am told that the library cant be read because it was created using a newer version of itunes. have tried to download 10.3 but it always tells me that i have and invalid hard drive j and to try again. any ideas?

    Older versions of iTunes cannot read libraries created with newer versions of iTunes. You need to have the same version of iTunes on all your PCs. Is that the case?
    As far as the problem installing iTunes goes, see this article from b noir on dealing with the problem:
    https://discussions.apple.com/thread/2450004
    If you get to the point where you need the Microsoft Installer cleanup utility, you will need more help as it has been withdrawn by Microsoft. but I am hoping the virtual drive trick will work,

  • How is the Login-validation.xml file is called when we do the validation i

    Hi ^^,
    please forgive me if I am a big long while explaining.
    when you are using the struts 2.0 the web.xml has a welcome-file-list. I have put index.html in that list so it pulls up first.
    It has the following tag
    <ul>
              <li><a href="roseindia/showLoginClientSideValidation.action">Login Application (Client Side Validation)</a></li>
            </ul>so this maps to struts.xml which contains the showLoginClientSideValidation.action tag
    <action name="showLoginClientSideValidation">
                   <result>/pages/loginClientSideValidation.jsp</result>
            </action>
            <action name="doLoginClientSideValidation" class="net.roseindia.Login">
                <result  name="input">/pages/loginClientSideValidation.jsp</result>
                   <result  name="error">/pages/loginClientSideValidation.jsp</result>
                   <result>/pages/Loginsuccess.jsp</result>
            </action>
              this displays the jsp "loginClientSideValidation.jsp"
    once you enter the details in the jsp and click submit the control goes to Login.java file as per the mapping in struts.xml given above
    This is just a simple java file which contains the execute() method. This method returns success or error.
    If success is returned then the Loginsuccess.jsp is invoked
    If error is returned then the loginClientSideValidation.jsp is invoked
    Well so far so good
    I have also understood that to use client side validation you use validate = "true" in loginClientSideValidation.jsp
    However what I am not able to understand is how the Login-validation.xml file is being invoked
    Any help would be highly appreciated.
    thanks and regards,

    Hi ^^^,
    i found something interesting that I want to share
    Validation rules are handled by validators, which must be registered with the ValidatorFactory (using the registerValidator method). The simplest way to do so is to add a file name validators.xml in the root of the classpath (/WEB-INF/classes) that declares all the validators you intend to use.
    validators.xml if being defined should be available in the classpath. However this is not necessary, if no custom validator is needed. Webwork will automatically picked up a predefined sets of validators defined in com/opensymphony/xwork/validator/validators/default.xml packaged together in xwork jar file that comes with webwork distribution.
    So this is clear that the validators are defined in validators.xml or default.xml
    What is still not clear is how is the Login-validation.xml being called by jsp page to do verification and then linking to validators.xml to apply the rules.
    However people have been telling me that ----" Struts 2.0 have inbuilt functionalities to validate the Parameters" and that i need to
    "Define configuration file *-validation.xml or use annotations
    i) className-validation.xml
    ii) place this file in the directory where .class file is placed example.Login should have Login-validation.xml
    Do you all think is this sufficient for an answer or should my search go on?
    thanks and regards,
    Prashant
    Edited by: pksingh79 on Sep 13, 2008 10:08 AM

  • Try to do my first XML Schema in SQL Server 2012 Mangement Studio(SSMS2012)-How to execute the xsd and xml files in SSMS2012?

    Hi all,
    I learmed the basic stuff of XML, DTD, DOM, etc. long time ago. Now, I came back to resume my XML journey and try to learn the XML Schemas, XPath and XQuery. I have Microsoft SQL Server 2012 Management Studio (SSMS2012) in our computer network. From
    Page 221 of the old Book "Beginning XML 2nd Edition" written by David Hunter, et.al., (published by Wrox), I copied the name5.xsd and name5.xml :
    <?xml version="1.0"?>
    <schema xmlns=http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.wrox.com/name" xmlns:target="http://www.wrox.com/name"
    elementFormDefault="qualified">
    <element name="name">
    <complexType>
    <sequence>
    <element name="first" type="string"/>
    <element name="middle" type="string"/>
    <element name="last" type="string"/>
    </sequence>
    </complexType>
    </element>
    </schema>
    <?xml version="1.0"?>
    <name
    xmlns=http://www.wrox.com/name"
    xmlns:xsi="http://www.wrox.org/2001XMLSchema-instance"
    xsi:schemaLocation="http://www.wrox.com/name name5.xsd"
    title="Mr.">
    <first>John</first>
    <middle>Frizgerald</middle>
    <last>Doe</last>
    </name>
    How can I execute these two files in my SSMS2012 for doing my first XML Schema trial?
    Please kindly help, advise and respond.
    Thanks in advance,
    Scott Chang

    Hi Eric Zhang, Thanks for your nice response.
    1) I saw the CREATE XML SCHEMA COLLECTION (Transact-SQL) and tried  its first example "Create XML schema collection in the database" in my SQL Server 2012 Management Studio (SSMS2012):
    -- Create a sample database in which to load the XML schema collection.
    -- Copied this set of code stsments from Microsoft Library (ms176009)
    -- ColesMS12_20a.sql (saved in C:/Documents/SQL Server Management Studio)
    -- 19 March 2015 1145 AM
    CREATE DATABASE SampleDB
    GO
    USE SampleDB
    GO
    CREATE XML SCHEMA COLLECTION ManuInstructionsSchemaCollection AS
    N'<?xml version="1.0" encoding="UTF-16"?>
    <xsd:schema targetNamespace="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ProductModelManuInstructions"
    xmlns ="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ProductModelManuInstructions"
    elementFormDefault="qualified"
    attributeFormDefault="unqualified"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" >
    <xsd:complexType name="StepType" mixed="true" >
    <xsd:choice minOccurs="0" maxOccurs="unbounded" >
    <xsd:element name="tool" type="xsd:string" />
    <xsd:element name="material" type="xsd:string" />
    <xsd:element name="blueprint" type="xsd:string" />
    <xsd:element name="specs" type="xsd:string" />
    <xsd:element name="diag" type="xsd:string" />
    </xsd:choice>
    </xsd:complexType>
    <xsd:element name="root">
    <xsd:complexType mixed="true">
    <xsd:sequence>
    <xsd:element name="Location" minOccurs="1" maxOccurs="unbounded">
    <xsd:complexType mixed="true">
    <xsd:sequence>
    <xsd:element name="step" type="StepType" minOccurs="1" maxOccurs="unbounded" />
    </xsd:sequence>
    <xsd:attribute name="LocationID" type="xsd:integer" use="required"/>
    <xsd:attribute name="SetupHours" type="xsd:decimal" use="optional"/>
    <xsd:attribute name="MachineHours" type="xsd:decimal" use="optional"/>
    <xsd:attribute name="LaborHours" type="xsd:decimal" use="optional"/>
    <xsd:attribute name="LotSize" type="xsd:decimal" use="optional"/>
    </xsd:complexType>
    </xsd:element>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    </xsd:schema>' ;
    GO
    -- Verify - list of collections in the database.
    select *
    from sys.xml_schema_collections
    -- Verify - list of namespaces in the database.
    select name
    from sys.xml_schema_namespaces
    -- Use it. Create a typed xml variable. Note collection name specified.
    DECLARE @x xml (ManuInstructionsSchemaCollection)
    GO
    --Or create a typed xml column.
    CREATE TABLE T (
    i int primary key,
    x xml (ManuInstructionsSchemaCollection))
    GO
    -- ////The following code statements are not used in order to create SampleDB
    -- Clean up
    ---DROP TABLE T
    ---GO
    ---DROP XML SCHEMA COLLECTION ManuInstructionsSchemaCollection
    ---Go
    ---USE Master
    ---GO
    ---DROP DATABASE SampleDB
    It worked and I got the following results:
    1 4 NULL sys 2009-04-13 12:59:13.390 2012-02-10 20:16:02.097
    65536 1 NULL ManuInstructionsSchemaCollection 2015-03-19 11:47:17.660 2015-03-19 11:47:17.660
    http://www.w3.org/2001/XMLSchema
    http://schemas.microsoft.com/sqlserver/2004/sqltypes
    http://www.w3.org/XML/1998/namespace
    http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ProductModelManuInstructions
    But, I don't undertand (i) what SCHEMA COECTION is, (ii) what <xsd:schema targetNamespace=.....</xsd:complexType> are, (iii) How I can specify my "project specific" schema in the Microsoft SCHEMA COLLECTION to check my xml file.
    2) I dived in the XQuery programmimng in SSMS2012 in the last few weeks. I used the examles of Ad-Hoc XML File Query by Seth Delconte (in
    httpS://www.simple-talk.com/content/print.aspx?article=1756) in my SSMS2012. They worked. But I don't understand the (i) Importing XML data using a function, (ii) Using the XQuery contans()
    function to find substrings, (iii)Efficiency comparisons in the article.
    Please kindly help me in enlightening me to resolve the difficulties listed in 1) and 2).
    Thanks,
    Scott Chang

  • HT1451 did anyone else find that an .itl or .xml file had to be present in order to open/ find the itunes library

    this is the correction to the article. REPLACE .itl and .xml files . itunes will not open without them. .itl especially
    long story of broken Macbook Pros. new one and the external drive had the only copy of iTunes. i had music on various drives so i started a new itunes library and imported all the music i could find, including from the 'only copy'. problem: a hundred playlists in painstaking order not there.
    followed the instructions from this article. except. when itunes opens, it has to have the .itl and .xml file present.
    i still had a spare copy of "only copy" so i replaced the NEW iTunes composite library's .itl and .xml files with the ones from 'only copy'. opened it up and there were all my playlists. now i may have to re-import music from various and tweak the playlists. but i don't have to RE-DO THEM. 

    CB many thanks!
    woke up today with the exact same problem... iMac locked up while playing a video podcast off my NAS
    (it was happily playing the audio even though the mouse was frozen)
    couldnt get permission control of my Library.itl so found your post,
    turned off the iTunes Server in my Synology (dont use it like that anyway) and rebooted the NAS.
    iTunes immediatley launched WITHOUT the lock, performed its repair check and up it came!
    THANK-YOU
    ...oddly I notice that I dont have permissions to ANY of my directorys/files,
    guess 'cause they are set in the Synology Shared Folder permissions?
    All are listed in the finder as:
    (unknown) R&W
    everyone NO ACCESS
    cockbongo wrote:
     I had exactly the same problem, but appear to have solved it
    Not sure what make/model NAS you have, but if it has an iTunes Server type service on it, turn it off. This won't delete your music folder, don't worry, but it will stop your NAS thinking it deserves exclusive access to the library files. Then reboot your NAS and voila, you can do what you like with the files.
    You can turn the iTunes service back on whenever you've finished doing what you need to do.
    Hope that helps.

  • Library not recognized - can't import .itl or .xml files

    Help! I opened iTunes today to update my podcasts and there's NOTHING there! (I have the newest version) I've been through troubleshooting to the best of my ability as well as checked the forums. My available .itl and .xml files are dated today - so they are empty. When I do a search for these files on my computer, I can find two older versions of them in the iTunes folder - one is listed under 'previous libraries' and one is just listed in the iTunes folder. But I cannot navigate to them through the import function of iTunes nor will it work if I use the 'open with' dialog box through the search window. They also do not show up in Windows Explorer. The only way I can see them is through the windows search function. I've tried copying them to different locations and then importing, but I get an error saying these were not properly exported files. The folder that I store my music in doesn't even appear to have all of the music in it anymore. Any help would be greatly appreciated. Thanks in advance!
    Kaymoe
    Sony Vaio Windows XP
    Sony Vaio   Windows XP  

    I have the exact same problem! Someone please help!

  • When I try to open a file I created in Pages, I get this: "The required index.xml file is missing."  This has happened many times and I have forgotten how I've worked around it.

    When I try to open a file I created in Pages, I get this: "The required index.xml file is missing."
    This has happened many times and I have forgotten how I've worked around it.

    That is wrong advice and you appear to have repeated it all over the forum.
    All Pages files no matter what version have the same file extension, .pages, despite being radically different formats and that is the problem. The System does not distinguish between them when you double click on the file, it opens the first version of Pages it encounters.
    You need to right click on the file and choose the correct App version for the file. Unfortunately there are no clues to tell you which is which.
    If you are unhappy with this and the removal of over 100 features plus the problems with transmitting files across devices, servers and different versions of OS X, rate/review Pages 5.5.2 in the App Store.
    Peter

  • TS1440 A flashing question mark appeared when I started my MacBook Pro, I've tried all the suggestions and nothing has worked. How can I back up my current files so I can reinstall Mavericks?

    I recently did a manual reboot after my MacBook Pro had frozen, and instead of the usual Apple and loading icon, it gave me the flashing question mark on a folder, which I've never encountered before. I looked up some possible reasons on my PC, and after reading that there's a problem with my HD I tried looking up how to back up my files so that I can do a clean reinstall of Yosemite (latest ver.). However, I've never used anything like Time Machine or anything else that could back up all my files, so it didn't sound like I could do anything about that at this point. I've also tried going into Disk Utility and attempting to repair the disk image. There was only 2 available, disk0 and the base system. I verified the base system, and told me there was nothing wrong (it didn't give me the option to repair anything either, on both available options). I don't think this is the right thing though, since my drive was called MacBook Pro HD. So basically this is the point I'm at now. Is there anything I can do that will repair my HD without erasing all my files?

    I've tried all the suggestions and nothing has worked.
    I verified the base system, and told me there was nothing wrong
    Hold the option key on boot to see if you can select your Macintosh HD.
    A flashing question mark or globe appears when you start your Mac - Apple Support
    You can boot into Recovery and re-install the OS X on top of what you have.  It will preserve your user data.
    command R on boot.
    Recovery  http://support.apple.com/kb/HT4718

  • How to create both a XML file and a check

    Hi,
    I'm currently implementing the use of XML files for payments in the USA and I run into a problem for check payments. We need to generate both an XML file, which needs to be sent to the bank for validation and the checks, which are printed by the finance department and then sent to the vendors. These checks are only paid when they match the XML file.
    We are using payment medium workbench for generating the XML file (DME structure) and on running F110 I get a nice XML file, however this prevents me from entering the printing form for check in the printout tab of F110.
    I tried to add the check in transaction OBPM1, but I cannot get it to work.
    Anny suggestions on how I can continue?
    Thanks in advance
    Peter Kauwenberg

    Hi Kauwenberg,
    You can add multiple payment in DMEE file but for that you have to change in DME properties where if you want sort according to payment method or dont want to club the different method in one line then add on more filed RZAWE from table FPAYH.
    I have used this options to one of my client where they want to add check payment with other payment method.
    Kindly try this and let me know in case of any issue.
    Regards,
    Dattatraya Biradar

  • SAX and XML file, how to?

    Hi,
    I'm going to use JAXP and SAX to read my application XML config file.
    But I'm lost, I don't know how to read the elements.
    How does it function, do I have to put in the startElement() method as many "if" as entitys I need to process?
    And how can I guess if an element belongs (is inside) one element or another?
    Example:
    <program>
    <printer id="xx" type="aa">
    <path> /aa/cc </path>
    </printer>
    <source>
    <path> /aa/bb </path>
    </source>
    </program>
    for this XML, how would you code it? this way?
    startElement (String uri, String localName, String qName, Attributes attributes) {
    if (localname.equals("printer")) {
    //get printer attributes
    } else if (localname.equals("source")) {
    //get source attributes
    thanks!

    i have one sample code through which u can read the elements from xml file.
    // File SaxLister.java
    import java.io.IOException;
    import org.xml.sax.Attributes;
    import org.xml.sax.SAXException;
    import org.xml.sax.XMLReader;
    import org.xml.sax.helpers.DefaultHandler;
    import org.xml.sax.helpers.XMLReaderFactory;
    public class SAXLister {
    public static void main(String[] args) throws Exception
    new SAXLister(args);
    public SAXLister(String[] args) throws SAXException, IOException
    XMLReader parser = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
    // should load properties rather than hardcoding class name
    parser.setContentHandler(new PeopleHandler( ));
    parser.parse(args.length == 1 ? args[0] : "parents.xml");
    /** Inner class provides DocumentHandler
    class PeopleHandler extends DefaultHandler
    boolean parent = false;
    boolean kids = false;
    public void startElement(String nsURI, String localName,
    String rawName, Attributes attributes) throws SAXException {
    // System.out.println("docEvents" + "startElement: " + localName + ","
    // + rawName);
    // Consult rawName since we aren't using xmlns prefixes here.
    if (rawName.equalsIgnoreCase("name"))
    parent = true;
    if (rawName.equalsIgnoreCase("children"))
    kids = true;
    public void characters(char[] ch, int start, int length) {
    if (parent) {
    System.out.println("Parent: " + new String(ch, start, length));
    parent = false;
    } else if (kids) {
    System.out.println("Children: " + new String(ch, start, length));
    kids = false;
    /** Needed for parent constructor */
    public PeopleHandler( ) throws org.xml.sax.SAXException {
    super( );
    // File people.xml
    <?xml version="1.0"?>
    <people>
    <person>
         <name>Ian Darwin</name>
         <email>http://www.darwinsys.com/</email>
         <country>Canada</country>
    </person>
    <person>
         <name>Another Darwin</name>
         <email type="intranet">afd@node1</email>
         <country>Canada</country>
    </person>
    </people>
    I hope this gives u a better understanding of how SAX parser works..
    Kindly note u need xml.jar and xerces.jar in ur classpath to run above program.
    Regards,
    Nikunj

Maybe you are looking for