Reading the Semantics of String

Hi, Can anyone help me out. I am working on a Interactinve TV Application and I want to publish some contents. When we publish, All the contents of the application merge with an XML or someother markup language (WML etc). For this we have to escape all the special characters. Like
\' - '
< - &l t; (without space, I put space because Explorer converts it to <)
-&g t; (without space, I put space because Explorer converts it to >)& - &
etc.
Everything worked fine, but now our requirements are changed and we need to implements links in a String.
For example Now I have a String like this:
My name is <Raheel> and I am a <Software Engineer>. My company is ABC Limited
And I want to change this string to
My name is &l t;Raheel&g t; and I am a &l t;Software Engineer&g t; . My company is ABC Limited
But the < and > of link should not be changed, How do I solve this problem. How do I read the semantic of the String. Does anyone have any idea.
I hope I explain enough to understand.
Thanks
Raheel

The way I usually handle problems of this sort is with a state based lexical analyser. You define a set of parsing states like "Parsing plaintext", "Having just read a <", "Inside the quotes of a reference" and so on and label them with int values.
Your parser reads the input character by character and depending on the combination of the character being read, and the current parser state, it emmits characters to the result string and changes to a new state for the next character.
So, for example, if you are in state "Parsing Plaintext" and you read a < you change state to "Having read < and don't emit the < If you are in state "Having read < and you read anything other than "a" you emit &lt; and return to "parsing plaintext".
You might use a StringCharacterIterator or get your characters from a Reader.

Similar Messages

  • Issue with applet reading the zero-length string values

    In my application the javascript function is setting the values read from the text fields to an applet. If the text fields are blank the javascript is setting blank value only but in the applet the values have become null. Please can any one let me know what exactly is the problem here?
    Its working fine in jdk 1.6.0 I upgraded it to 1.6.0_12 update and facing this problem.

    In the applet class its checking the same way but there i m getting the value as 'null' for the parameter set from javascript.
    But in the javascript if i try to alert the value its giving me blank i.e., zero-length string.
    When i tried to google it I found the following information,
    In JDK 1.1 the Java language specification was loose in dealing with null and zero-length strings in the class libraries. Some APIs may treat a zero-length string as null, while other APIs may treat null as it is. In Java SE, the Java language specification has been tightened up to specify what the exact behavior should be.
    This issue is not fixable. Thus, in Java SE an applet that relies on the APIs to treat null as a zero-length string may result in an exception.
    Is there anything to do with this?
    The strange thing is it working fine in 1.6.0 i mean i m getting the value of parameter as blank in applet which is same set from javascript.
    But if the same is not working in 1.6.0_12 inspite of javascript setting the blank value, the applet is reading it has 'null'.

  • Read the first string in the line, skipping the whitespace ---Possible???

    I am parsing through the following file:
          * AOCSOnLupda.h
          *  Created on: 20.07.2010
          *      Author: perv_na
    #ifndef AOCSONLUPDA_H_
    #define AOCSONLUPDA_H_
    // holds the value of on_lupda
    namespace AOCS {
         class AOCSOnLupda{
              private:
                    /* public part
              public:
    #endif /* AOCSONLUPDA_H_ */My main task is to, go inside this file, check if the namespace and class name provided by the user matches the one's inside this file. And then write a boolean initialization (e.g. boolean checked = 1).
    The problems I am facing is that, when I read through each line I want to make sure that there is no Block Comment signs or // sign in the beginning of the line. So that I am sure that I am not writing the initialization inside a comment line or something.
    My problem is I am not at all being able to read the first word of a line (without the whitespace).
    Can someone please tell me how you can skip the first whitespaces in a newly read line, and retrieve the first chars/String? Like in the line:
                   /* public part
              public:there is white space before the start and end of the block comment. And also in front of the word "public:"
    How do I get my hands on the start and end of block comment character and also "public:" by skipping the white spaces in front?
    Thank you
    newbie
    Edited by: JFC_newbie on Jul 27, 2010 8:46 AM

    Hi,
    thank you for the link ... but I am actually trying to do by myself.
    BufferedReader in;
              String lineInFile;
              try {
                   in = new BufferedReader(
                             new FileReader(
                                       "C:/Users/jui/Eclipse/eclipse-java-helios-win32-x86_64/javaWorkspace/FilePathSearchCreateTest/aocsFiles/AOCSOnLupda.h"));// open
                   while ((lineInFile = in.readLine()) != null) {
                        if((lineInFile.trim().length())!=0){   //If not a Blank Line then...
                        *     //Read the first non-whitespace char in the read line                         *                     
                             String [] tempLine = lineInFile.split("\\s");
                             System.out.println(tempLine[0]);
                   in.close();// safely close the BufferedReader after use
              } catch (IOException e) {
                   System.out.println("There was a problem:" + e);
              }But it's not working. I need my code to read the first char/String in a newly read line, by skipping the first whitespaces.
    Would really really appreciate some tips. thank you.

  • How to read the API

    I am trying to understand how to read the Java API. I have bought Oracle's Books "Java The Complete Reference" and "Java A Beginners Guide" but am still unsure how to read the API.
    Let me clarify what I'm asking to avoid confusion.
    The class java.util.ProcessBuilder http://download.oracle.com/javase/7/docs/api/
    Has a Constructor section that lists
    Constructor and Description
    ProcessBuilder(List<String> command)
    Constructs a process builder with the specified operating system program and arguments.
    ProcessBuilder(String... command)
    Constructs a process builder with the specified operating system program and arguments.
    How do I read the ProcessBuilder(List<String> command) so that I can understand it and implement its use?
    Later when it talks about methods such as List<String>      command()
    Returns this process builder's operating system program and arguments.
    How do I understand this and make use of the method?
    Is it possible for this to be explained to cover the whole API so that when a class is looked up the constructor and methods are explained that someone who does not understand can take any class and have the constructor and methods from the API and know how to implement them?
    Thank you
    FtroopSon

    FtroopSon wrote:
    My Instructor said we can not work with others on our project, so instead of violating that rule, I asked something about JAVA here. My question was general enough to not violate the instructors rule, but specific enough to learn what I felt I was missing.I hope you don't think I was suggesting you're doing anything wrong - far from it - I was simply saying that ProcessBuilder isn't the first class I would choose if I was trying to get familiar with the Java API pages.
    As with a lot of questions like this, Google is your friend. A Google of "using ProcessBuilder" gave me a pile of useful pages on how to use the class (which the API docs aren't always wonderful at doing), including some common 'gotchas' - although many of these are related to <tt>Runtime.exec()</tt>, which Process/ProcessBuilder was created to improve.
    One of those pages was for [url http://commons.apache.org/exec/index.html]Apache Commons Exec, which you might also want to look at (although it does require a download, and that might violate the rules of your exercise too). I've never used it myself though, so I can't comment on how good it is.
    Alternatively, it might be worth talking to your instructor and explaining your problem. Most of us are reasonable chaps, and s/he might be able to provide you with some good tips.
    Remember: plagiarism is the programmer's stock-in-trade. There's nothing wrong with using something written by someone else as long as you attribute it - that is, after all, what classes are all about :-).
    Winston

  • My test instrument is outputting a 5 line string but labview only read until the carriage return. how can I get it to read the whole string?

    I have a labview sub-VI reading the string being outputted by a pH meter.  The meter outputs a 5 line string and labview is only reading up to each lines carriage return, there-by giving me 5 separate strings is there anyway to rectify this and have the 5 line read as one string?
    NAS1
    St Petersburg FL
    Labview 2010

    Yes, LabVIEW will automatically update. What happens is that the old serial functions still exist in 7.1 and above but the code (the block diagram) has been modified to use VISA functions. Older versions of LabVIEW are fully supported in this manner. The only way you can avoid the automatic update is to have the old serial functions in an llb and your top level VI refer to these. Having any VI that was part of vi.lib in an llb is a very bad idea and the way to fix things is to remove any VIs in the llb that are part of the LabVIEW distribution.
    I don't remember how the old serial config worked and what the new version does with the VISA Configure Serial Port. Your program should only have a single serial config and you might just be able to directly replace that with the VISA configure Serial Port.

  • I want to read the content of a text file dropped in a watched folder into a string variable

    I have a workbench process with 2 variable.
    inDoc (DataType=Document/input/required)
    outStr (DataType = String/output)
    The document being passed to the workflow is a text file with 4 lines of text in it.  when the text file is dropped into the watched folder, it will be assigned to the inDoc parameter in the workflow.
    My workflow needs to extract the 4 lines of text and write it into a string (outStr).
    Id like to use the FileUtilsService.ReadString service but i can't since its input parameter is the file path.  When i do, i get the following error...
    Caused by: ALC-FUT-001-011: File rO0ABXNyABZjb20uYWRvYmUuaWRwLkRvY3VtZW50yAEFUxsO+CEDACNJAAtfY2FsbGJhY2tJZFoADV9kZXNlcmlhb Gl6ZWRJABBfZGlzcG9zYWxUaW1lb3V0WgAJX2Rpc3Bvc2VkWgAZX2lzRGlzcG9zYWxUaW1lb3V0RGVmYXVsdFoAE19 pc1RyYW5zYWN0aW9uQm91bmRKAAdfbGVuZ3RoSQAOX21heElubGluZVNpemVaAAhfb3duRmlsZVoAC19wYXNzaXZhd GVkWgALX3BlcnNpc3RlbnRJABFfc2VuZGVyQ2FsbGJhY2tJZFoAEV9zZW5kZXJQYXNzaXZhdGVkWgARX3NlbmRlclB lcnNpc3RlbnRJAA5fc2VuZGVyVmVyc2lvbkkABl9zdGF0ZUwAC19hdHRyaWJ1dGVzdAATTGphdmEvdXRpbC9IYXNoT WFwO0wACF9jYWNoZUlkdAAfTGNvbS9hZG9iZS9pZHAvRG9jdW1lbnRDYWNoZUlEO0wADF9jYWxsYmFja1JlZnQAIUx jb20vYWRvYmUvaWRwL0lEb2N1bWVudENhbGxiYWNrO0wADF9jb250ZW50VHlwZXQAEkxqYXZhL2xhbmcvU3RyaW5nO 0wAC19kYXRhQnVmZmVydAAeTGNvbS9hZG9iZS9zZXJ2aWNlL0RhdGFCdWZmZXI7TAAPX2V4cGlyYXRpb25UaW1ldAA QTGphdmEvbGFuZy9Mb25nO0wABV9maWxldAAOTGphdmEvaW8vRmlsZTtMABBfZ2xvYmFsQmFja2VuZElkdAAhTGNvb S9hZG9iZS9pZHAvRG9jdW1lbnRCYWNrZW5kSUQ7WwAHX2lubGluZXQAAltCTAAMX2lucHV0U3RyZWFtdAAVTGphdmE vaW8vSW5wdXRTdHJlYW07TAAPX2xvY2FsQmFja2VuZElkcQB+AAhMAAxfcHVsbFNlcnZhbnR0ACRMY29tL2Fkb2JlL 2lkcC9JRG9jdW1lbnRQdWxsU2VydmFudDtMABFfcmFuZG9tQWNjZXNzRmlsZXQAGkxqYXZhL2lvL1JhbmRvbUFjY2V zc0ZpbGU7TAAVX3NlbmRlckNhbGxiYWNrUmVmSU9ScQB+AARMABZfc2VuZGVyR2xvYmFsQmFja2VuZElkcQB+AAhMA A1fc2VuZGVySG9zdElkcQB+AARMABVfc2VuZGVyTG9jYWxCYWNrZW5kSWRxAH4ACEwAGl9zZW5kZXJQdWxsU2VydmF udEpuZGlOYW1lcQB+AARMAARfdXJsdAAOTGphdmEvbmV0L1VSTDt4cHcGAAAAAwAAcHd1AHMwOjA6MDowOjA6MDowO jEvMTI3LjAuMC4xLy8vLy8vLy8vZmU4MDowOjA6MDo3NDMyOmU0OWQ6NmUzMToxNTU0JTEwLzEwLjI0LjIzOS4xMjY vZmU4MDowOjA6MDowOjVlZmU6YTE4OmVmN2UlMTEvLy8vdXIAAltCrPMX+AYIVOACAAB4cAAAAcRJTU01MjU3XzAxL TIwMTFfMXwwMXx8YXx8fHxGZW1hbGV8MjAwMHw2fDh8Y3wyNTZ8MjU2fDkxMnwwMXx8fHx8fHx8Tnx8fHx8fHx8fHx 8fHx8fHx8fHxZfHx8fHx8fHx8fDAyfHx8fHx8TnwyMDEyfDJ8MTR8DQpJTU01MjU3XzAxLTIwMTFfMnx8fHx8fHx8f Hxhc2RmfDI1NnwyMDEyfDAyfDAxfDIwMTJ8MDN8MDJ8fHx8YXxhfDI1Mnx8fHxZfHx8fHx8fHx8fHx8fHx8DQpJTU0 1MjU3XzAxLTIwMTFfM3xOfHx8fHx8fHx8fDIwMDB8Nnx8fGFzZGZ8YXNkZnxhc2RmfDI1Nnx8fHx8fHx8fHx8fHx8f Hx8fHx8DQpJTU01MjU3XzAxLTIwMTFfNHxOfE58fE58TnxOfHxOfE58fE58TnxOfA0KSU1NNTI1N18wMS0yMDExXzV 8U2luZ2xlfDAxfHwyMDEyfDAyfDE4fDIwMTJ8MDN8MDN8MjM0fGFzZGZ8fGFzZGZhc3x8fHxFeGNoYW5nZS1Qcm8uO S40MDEuRnVsbC5XSU4uZW5fQ0EuRU5VLTEwLTIwMTF8DQoNCnBwdwYAAAAAAAB0AAp0ZXh0L3BsYWlucHNyABFqYXZ hLnV0aWwuSGFzaE1hcAUH2sHDFmDRAwACRgAKbG9hZEZhY3RvckkACXRocmVzaG9sZHhwP0AAAAAAAAx3CAAAABAAA AADdAAKd3NmaWxlbmFtZXQAJ0M6XFVzZXJzXENodWxseS5QYXJrXERlc2t0b3BcaGRzY2FuLnR4dHQACGJhc2VuYW1 ldAAKaGRzY2FuLnR4dHQABGZpbGVxAH4AFXh3NwAtYWRvYmUvaWRwL0RvY3VtZW50UHVsbFNlcnZhbnQvYWRvYmVqY l9MQ19ERVYx//////////94 does not exist.
    at com.adobe.livecycle.fileutils.FileUtilsService.readDocument(FileUtilsService.java:363)
    which is what i expected...
    I've also tried with the Script.executeScript to call some java code but im not too strong in java and in all the examples i find, the file pointer requires a file path.
    import java.io.*;
    FileInputStream f = new FileInputStream(patExecContext.getProcessDataValue("/process_data/inDoc"));
    OR
    File f = new File(patExecContext.getProcessDataValue("/process_data/inDoc"));
    OR
    File f = patExecContext.getProcessDataValue("/process_data/inDoc");
    Any clue how to resolve my problem?

    Try the following code snippet to read the String content from the file recieved through watched folder endpoint.
    com.adobe.idp.Document inputDoc = patExecContext.getProcessDataDocumentValue("/process_data/inDoc");
    java.io.InputStream inStream = inputDoc.getInputStream();
    byte[] dataBuffer = new byte[inStream.available()];
    inStream.read(dataBuffer);
    String strData = new String(dataBuffer);
    patExecContext.setProcessDataStringValue("/process_data/outStr",strData);
    The code is not tested, hence if you find any mistakes, correct and test the functionality.
    Nith

  • While saving a pdf file opened by foxit reader, the filename will be some strings

    '''''i opened a pdf file in firefox with foxit reader, the filename was ,for
    example, ol20120327.pdf, and i click the save and i got i file , the filename just some strings , not the real name. It really bothers me for a long time. ps: while in ie, maxhon ,they got the right name.
    i don't want change my default browser; i love firefox. i hope the problem would be solved. Thanks a lot''.'''

    try adobe reader

  • Getting the same return string while reading multiple times from a GPIB instrument

    I'm having problems reading data from a GPIB instrument.
    I'm using a sequence similiar to this:
    1. Send a "MEASCALRES?" command to the calibrator to measure the current pressure.
    2. Read the result string sent from the calibrator.
    3. Send a "SYST:ERR:NEXT?" query to check if an error has occured.
    4. Recieve the error string from the calibrator.
    When running the program, the error string sometimes contains the same data as the pressure reading. For example, if the calibrator's pressure output string was "1.0000000e2", the error string might be "1.0000000e2" or sometimes just "20, No Errors", with the extra "2" added to the normal "0, No Errors".
    The problem a
    ppears to occure randomly, a rough estimate would be that it happens one time out of 50 readings.
    Are there any relevant GPIB card settings I can change to fix the problem?

    It looks to me that more data is send or data end is signalled to early by hte iocard.
    Maybe you should check the gpib bus cable speed. The default is much too fast for almost all instruments. Put it on 2 microseconds (the slowest speed). And we always disable autopolling, to prevent asynchronous actions.
    greetings from the Netherlands

  • Read the file and write the data into string or int

    Ok, here's another rookie question.
    I got to read the line from the file and store it in the memory as string or integer.
    I wrote this code:
    File inputFile = new File("c:/xxx.yyy");
    String outputString = new String();
    FileReader c1 = new FileReader(inputFile);
    StringWriter d1 = new StringWriter(outputString);
    int data;
             while((data = c1.read()) != -1)
                 d1.write(data);
                 System.out.println(data);
             c1.close();
             d1.close();This is how I see it, but it cannot be even compiled because there is no such thing as StringWriter(String) wich I find completely irrational. So tell me, am I retarded or what? No, but seriosly, please help the newbie to understand these streams, am I supposed to use some kind of buffer? Any help appreciated.

    A String is an immutable. You cannot update a String.
    A new String() is basically the same as an empty String ""
    An empty StringWriter can be created with new StringWriter().
    If you use a BufferedReader you can call readLine().
    BufferedReader in = new BufferedReader(new FileReader(filename));
    String line;
    while((line = in.readLine()) != null) {
      System.out.println(line);
    }

  • How to read the string present in the captcha?

    hi all,
    Can anyone help me out to read the string present in the captcha.
    When a user registers an ID or stuff the user is prompted to enter the image shown.
    i need a code to read the string present in the captcha image.
    hope u get my point.please help me out in coding out for the above.
    Thanks,
    vish

    so dude basically u r trying to make a spam engine?!
    do u think any1 would help u here ? lol
    by the way why do u really need that code ? what are ur intentions ? lol

  • Reading the portion of a string

    I have a table with one column " otname "
    table1.otname contains multiple rows of alpha-numeric string resembling the following data sample:
    11.10.32.*12*.U.A.F.3.2.21.249.1
    2001.1.1003.*8281*.A.LE.P.P
    2010.1.1003.*8261*.A.LE.B.B
    I want to read the fourth number in every string ( part of the string in bold ) and write a query in Oracle 10g
    to read its description stored in another table. My dilemma is writing the first part of the query.i.e. choosing the fourth number of every string in a table
    My second query will be something like this:
    select description_text from table2 where sncode = 8281  -- fourth part of the data sample in every stringMany thanks.
    novice

    Yes. that seems to be the case.
    The solution was provided based on the sample data that you have provided. One assumption made was that your string will atleast contain 4 '.'. If this is not the case you can use the solution provided by Michael or you can change the above mentioned solution to:
    SELECT   description_text
       FROM   table1, table2
      WHERE   SUBSTR (otname,
                               INSTR (otname,'.',1, 3) + 1,
                               CASE
                                   WHEN ( INSTR (otname, '.', 1, 4)
                                              - INSTR (otname, '.', 1, 3)
                                                   - 1) < 0
                                             THEN
                                                LENGTH (otname)
                                             ELSE
                                                ( INSTR (otname, '.', 1, 4)
                                              - INSTR (otname, '.', 1, 3)
                                                   - 1)
                               END)  = sncodeMichael solution is simple though. I wonder why it didn't pull any data for you. Seems to be working fine for me.
    Could you post your SQL Session running the query provided by Michael.
    Regards,
    Jo

  • I recently had a friend pass away and wanted to grab the photos and read the imessages we exchanged, but i deleted the string.  is there anyway to recover this imessage stream?

    I recently had a friend pass away and wanted to grab the photos and read the imessages we exchanged, but i deleted the string.  is there anyway to recover this imessage stream?

    There are two methods to recover deleted imessages.
    1. Restore them from a previous iTunes or iCloud backup.
    iOS: How to back up and restore your content:
    http://support.apple.com/kb/HT1766
    <Link Edited by Host>

  • Iphone 3G and wifi problems.  I've been reading the string about this from last year.  I have an iphone 3G with the latest ios 4.2.1 software.  Every time I connect to my home wifi - Belkin N  - it comes up after a few minutes with "Incorrect Password".

    I re-enter the password correctly but it keeps happening.  Any suggestions?

    I have a belkin n surf as well and i have got this and other problems. my iphone 3g and 4 often keep on loosing connectivity. especially if the bluetooth is one (either connected or not). it often fails to find my wifi network after waking up from sleep.
    the problem i think is most certainly with belkin n. its one of the worst routers out there. unfortunately i didn't read the reviews before buying it. i have other problems with it to like connecting it to a dc++ hub. the setting up for port forwarding is a pain and it tends to connect to the internet on its own even though there are no settings to disable automatic connection.
    i was later told by many people online and also read it in the reviews that its one of the very bad router out there along with other belkin routers. belkin has even arranged a replacement for me as its under warranty but i'm avoidng travelling to the other end of the city cause i know all models have the same problem. the worst of them all is a mere 3mbps transfer speed form one computer to another over wifi file sharing even if they both are connected via 802.11n and are placed withing full signal coverage range, with no firewall or security on either on the machines or router. tried it over several macbooks and windows pcs.
    i'm getting lynksys for good.

  • How do I read the XML string using Http response/request?

    When my HTTP POST action is perform, the action will return me a XML string as shown in the link, https://www.neteller.com/gateway/netdirectv4.cfm?amount=150.00&net_account=458415554241&secure_id=896365&bank_acct_num=6789&currency=USD&merchant_id=1234&merch_transid=1102&merch_account=john123&custom_1=test123&custom_2=test123&custom_3=test123&test=1
    The above XML string will be send back by one of the payment gateway.
    How do I retrieve all the attribute name and value from the XML string so that it can be stored in my database?
    The XML string will be as shown below:
    <?xml version="1.0" encoding="ISO-8859-1"?><netdirect version="4.0">
              <approval>yes</approval>
              <amount>150.00</amount>
              <trans_id>403070</trans_id>
              <error>none</error>
              <fee>4.35</fee>
              <time>{ts '2006-06-23 06:14:19'}</time>
              <firstname>Test</firstname>
              <lastname>Test</lastname>
              <email>[email protected]</email>
              <custom_1>test123</custom_1>
              <custom_2>test123</custom_2>
              <custom_3>test123</custom_3>
              <dafee>0.00</dafee>
              <client_currency>USD</client_currency>
              <client_amount>150.00</client_amount>
              <merchant_currency>USD</merchant_currency>
              <merchant_amount>150.00</merchant_amount>
              <fxrate>1.0</fxrate>
              </netdirect>

    How about parsing the XML? Check out JAXP.
    http://java.sun.com/webservices/jaxp/index.jsp

  • How to read the content in one node of XML in Java? Pls help

    My dear brothers,
    I am a newbie of XML, I have a exercise which is creating a Tree View from XML file. But the trouble is I do not know how to read the content in one node of XML file. I decide to use the algorithm as following:
    1. Create a GUI form which gives the ability for user to choose a XML file (ok)
    2. Load XML and return the file (ok)
    3. Read the file from node to node to create the node in Tree View (?!)
    Please help me, and if you are enough kind, please give me an small example to easy understand. Thanks in advance.
    Hoang Yen Binh

    I hope this one helps you.
         <ABC Type="ProductBased" ProdName="One" Location="India">
              <CEO>Raj</CEO>
              <Finance>Vikram</Finance>
              <HR>Karthik</HR>
              <Technical>Satish</Technical>
         </ABC>
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.NamedNodeMap;
    import org.w3c.dom.Attr;
    import org.w3c.dom.NodeList;
    import org.w3c.dom.Node;
    import org.w3c.dom.DOMException;
    import javax.xml.parsers.ParserConfigurationException;
    import org.xml.sax.SAXException;
    import java.io.File;
    import java.io.IOException;
    public class XmlReading {
         Document doc;
         Element element;
         public static void main(String[] args) throws Exception{
              XmlReading xr = new XmlReading();
              xr.getXmlParser(args);
         public void getXmlParser(String[] args) {
              DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                   if(args.length != 1) {
                        System.err.println("Argument Required");
              try {
                   DocumentBuilder builder = factory.newDocumentBuilder();
                   doc = builder.parse(new File(args[0]));
              }catch(ParserConfigurationException e1) {
              }catch(SAXException e2) {
              }catch(IOException e3) {
              getAttributes();
         public void getAttributes() {
              // Retrive the entire Document from the Dom Tree
              element = doc.getDocumentElement();
    //          System.out.println(element);
              NamedNodeMap attrs = element.getAttributes();
              // Get number of attributes in the element
         int numAttrs = attrs.getLength();
         // Process each attribute
              for (int i=0; i<numAttrs; i++) {
                   Node node = attrs.item(i);
                   // Get attribute name and value
                   String attrName = node.getNodeName();
                   String attrValue = node.getNodeValue();
                   System.out.println(attrName + ": " + attrValue);
              String s1 = element.getTagName();
              System.out.println(s1);
              // To get all the elements in a DOM Tree
              NodeList nl1 = element.getElementsByTagName("*");
              int i2 = nl1.getLength();
              System.out.println(i2);
              for(int i=0; i<i2; i++) {
                   System.out.println(nl1.item(i) + "\n");
    }

Maybe you are looking for

  • (MacBook Pro 15-inch, Early 2011) Wi-Fi: No hardware installed...

    The Wi-Fi hardware irregularly connects to the network. Once the WiFi is disconnected, it cannot be reconnected unless restart or shutdown. I restart or shutdown to "refresh" the scenario but the problem has grown more frequent. I can connect to the

  • File path as argument

    I need to pass the file path as argument to my java code. when i execute the code: java myJavaClass c:\folder\filename.txtWhen i use the above command i get an error message saying filename.txt does not exist. but such a file exist in the folder spec

  • Pie Chart Creation from set of Columns.

    Hi all, I have got a query in BW. the Query output looks like. A     B     C      D       E        F 1      2     2       3       4         5 So now the o/p gives a clear view that there are no rows in my Query. Now on the basis of this query i want

  • How to set the textfield not to scroll the text?

    hi to all.... what will i do if i want the textfield not to scroll the text if the text is very long.. what if i wanted the text will just display "this is a test..." a three dots will be display before reaching the end of the textfield... i tried ge

  • Steps to create the counter based Maintenance plan

    Hi! Can any body give "Steps to create the counter based Maintenance plan" (Mater Data,Transactional Data and Customizing Data creation) Regards, MDSFR