How to retrieve value from xml file

hi all,
can somebody pls tell me how to retrieve value from xml file using SAXParser.
I want to retrieve value of only one tag and have to perform some validation with that value.
it's urgent .
pls help me out
thnx in adv.
ritu

hi shanu,
the pbm is solved, now i m able to access XXX no. in action class & i m able to validate it. The only thing which i want to know is it ok to declare static ArrayList as i have done in this code. i mean will it affect the performance or functionality of the system.
pls have a look at the following code snippet.
public class XMLValidator {
static ArrayList strXXX = new ArrayList();
public void validate(){
factory.setValidating(true);
parser = factory.newSAXParser();
//all factory code is here only
parser.parse(xmlURI, new XMLErrorHandler());     
public void setXXX(String pstrXXX){          
strUpn.add(pstrXXX);
public ArrayList getXXX(){
return strXXX;
class XMLErrorHandler extends DefaultHandler {
String tagName = "";
String tagValue = "";
String applicationRefNo = "";
String XXXValue ="";
String XXXNo = "";          
XMLValidator objXmlValidator = new XMLValidator();
public void startElement(String uri, String name, String qName, Attributes atts) {
tagName = qName;
public void characters(char ch[], int start, int length) {
if ("Reference".equals(tagName)) {
tagValue = new String(ch, start, length).trim();
if (tagValue.length() > 0) {
RefNo = new String(ch, start, length);
if ("XXX".equals(tagName)) {
XXXValue = new String(ch, start, length).trim();
if (XXXValue.length() > 0) {
XXXNo = new String(ch, start, length);
public void endElement(String uri, String localName, String qName) throws SAXException {                    
if(qName.equalsIgnoreCase("XXX")) {     
objXmlValidator.setXXX(XXXNo);
thnx & Regards,
ritu

Similar Messages

  • How to retrieve image from XML  file

    Hi All,
    I am new to XML. So any best guidance is appreciated.
    The application requirement is to display image retrived from uploaded xml file in file upload section of our application. And store that image in database.
    In my XML file , images & strings & numbers & booleans are there . I am able to save everything in database except images .
    I am using JSF, Seam & Hibernate combination. In my Hibernate entity class i took BLOB datatype for image.
    I am using following tags in my Xhtml file to display image
    <s:graphicImage value="#{hibernateentitybean.picBlobtype}" height="200" width="200">
    <s:transformImageSize width="200" height="200" />
    <s:transformImageType contentType="image/jpeg"/>
    But image is not displayed in Xhtml file
    I am using org.w3c.dom.Document for retrieving node name & corresponding value in that node in XML file.
    I am getting code like below for Image when i am logging all values from XML files in my bean class .
    x0lGQRQAAAABAAAAAAAAAFJHAQARAAAAVwBhAHQAZQByACAAbABpAGwAaQBlAHMALgBqAHAAZwAAAP/Y/+AAEEpGSUYAAQIBAGAAYAAA/+0YLl
    I want to convert this value to image. So i can convert image to bytes and store in BLOB.
    Can anyone guide me ? or any other approach .
    Thanks in advance for any reply.
    Regards,
    Naresh

    Dan_Koldyr wrote:
    agree, it's really odd. Just reread OP and it says:
    NareshDharmiVatsal  wrote:
    want to convert this value to image. In any case it doesn't get worth then another single code line:
    final String cdata = "x0lGQRQAAAABAAAAAAAAAFJHAQARAAAAVwBhAHQAZQByACAAbABpAGwAaQBlAHMALgBqAHAAZwAAAP/Y/+AAEEpGSUYAAQIBAGAAYAAA/+0YLl";
    final sun.misc.BASE64Decoder decoder = new sun.misc.BASE64Decoder();
    final byte[] data = decoder.decodeBuffer(cdata);
    Blob blob = new SerialBlob(data);//or what ever other DB-specific blob implementaiton Did i answered original question? Any more comments to my first replay?I can comment on this latest code. The package sun.misc is private to Sun (Oracle now of course). It is undocumented and may change or be removed altogether in a future release. There is a good free open source Base64 decoder in the Jakarta Commons Codec library.

  • How to retrieve data from xml file into obiee reports

    Hi all,
    I've got a situation here. A xml file is stored as blob in oracle database table. Now i need to retrieve data/info from that xml file into obiee reports. How am i supposed to proceed with this ?

    I will go for a table function:
    http://gerardnico.com/wiki/database/oracle/table_function
    In two words, you can create a function that behave as a table. Then you create a function to pick up your xml, you parse it and you send back the rows.
    I know that Oracle has also a library for XML files but I never use it until now.
    Success
    Nico

  • How to parse contents from XML file in Java

    Hi All,
    I have a scenario like this . I have one xml file with key value pairs of ( name , URL ) . I have retrieved contents from XML file , now I want to parse these contents and store in a bean object.
    How to parse Contents of XML file??
    Thanks in advance,
    Rajendra.

    Hi All,
    I have a scenario like this . I have one xml file with key value pairs of ( name , URL ) . I have retrieved contents from XML file , now I want to parse these contents and store in a bean object.
    How to parse Contents of XML file??
    Thanks in advance,
    Rajendra.

  • How to remove Unicode from XML file

    I get following error when unmarshal xml:
    [java] org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0x15) was found in the element content of the document.
    Anyone know how to remove Unicode from xml file? Can I remove the unicode by rebuild the file?
    Thanks

    These sort of error usually occur when you're using a different character encoding to read the file than the one you wrote it with. Perhaps if you were to post the problem section of the file and/or the code that created it in the first place.

  • How to extract data from XML file with JavaScript

    HI All
    I am new to this group.
    Can anybody help me regarding XML.
    I want to know How to extract data from XML file with JavaScript.
    And also how to use API for XML
    regards
    Nagaraju

    This is a Java forum.
    JavaScript is something entirely different than Java, even though the names are similar.
    Try another website with forums about JavaScript.
    For example here: http://www.webdeveloper.com/forum/forumdisplay.php?s=&forumid=3

  • Retrieve data from XML file

    How can I import a XML file into pdf doc and how can I retrieve its data as string, in order to populate a drop down List, without using XML Schema Data Connection.
    Thank you for your time!

    First of all you cannot load an XML file in Designer without Reader Extensions, either using xfa.host.importData or any or the import methods in AcroForm javascript. Also, since the XML objects where not available in 6, you cannot parse an XML file in anything other than version 7 of Reader/Acrobat.
    So, if you do have Reader 7 (Reader-Enabled) or Acrobat 7, you could use the Attachment object to load the XML file and in turn use the XML object to parse and extract the XML data.
    For example, placing the following code on a button will prompt the user to select an XML data file and manually parse it for data.
    if (app.viewerVersion >= 7)
    event.target.importDataObject("XMLData");
    var oData = event.target.getDataObjectContents("XMLData");
    var sData = util.stringFromStream(oData);
    var oXML = XMLData.parse(sData, true);
    event.target.removeDataObject("XMLData");
    // Populate Fields
    TextField3.rawValue = oXML.MyField1.value;
    TextField4.rawValue = oXML.MyField3.value;
    TextField1.rawValue = oXML.MyField2.value;
    else {
    app.alert("Acrobat 7.0 or later is required");
    My external XML file is:
    <?xml version="1.0" encoding="UTF-8"?>
    <MyProperties>
    <MyField1>A</MyField1>
    <MyField2>B</MyField2>
    <MyField3>C</MyField3>
    </MyProperties>
    Once the data is parsed, you can access it through the same hierarchy as Designer. It actually generates an XFAObject to represent each data node within the XML Document.
    The other thing to note is that you cannot load data automatically from an init or calc event. You MUST have some user interaction (i.e. on the click event of a button)

  • How to retrive data from .XML file to JMS

    hi friends.. this is vamsi from india.. i have been working on jsp, java bean, xml, jms, message driven bean , ejb and database from last couple of days. but i am not able to retrieve data from fields in xml file to jms. can any one help me out in retrieving the data from xml to jms..
    thanking you,
    vamsi.

    Database but we are not able to retrieve the values
    from XML to JMS."We are not able to" is too vague a statement. An answer to this could well be "Did you turn your computer on?"
    So again, please post formatted code showing what you have done and where you are stuck.
    Perhaps an error message and/or a stack trace if appropriate.

  • How to show records from xml file

    HI All
    I have created one region its actually search region
    which having 5 items and result table region
    I want to search records based on that 5 items and want to show output in table
    I have table name as hr_api_transactions which contains lot of columns
    and that table also contain one column
    name as TRANSACTION_DOCUMENT of type CLOB()
    that columns xml files for each record
    I want to extract data from that xml file and want to display.

    I have created one region on seeded page
    in that region I have created one table for output
    that region is search region
    which having 5 items of textfield and 2 items of type submit button
    GO and Clear
    I want to search based on that 5 items
    I want to display records in table that I have created on that region
    I have one seeded table
    that contain one column
    that column contain xml file for each individual records
    that xaml file contains values what I want to display
    MY problems are
    how can I extract data from xml file?
    how can I show all values for each records on that table?
    how can I search based on that 5 items?
    now I am able to find out single value from that XML file
    by using SQL command
    select xmltype(transaction_document).extract('//IrcPostingContentsVlEORow/CreationDate/text()').getStringVal() CreationDate
    from hr_api_transactions
    where transaction_ref_table = 'PER_ALL_VACANCIES'
    and transaction_ref_id = 4693;how can I extract more than one records from that XML file

  • How to Pass values from XML to JSP??? Urgent Please Help me

    Hi guys,
    I am new to XML, I want to pass values from XML to JSP. I have a xml file with attributes, I should send this values to a JSP file. How is it??? Please Help guys.... its very urgent. Please send me how to do it with an example or atleast any urls related that....
    Looking for ur favourable reply.
    Thanks in advance,
    Sridhar

    in a servlet :
    parse your xml file (see how at the end of the post) and
    put the values you want in the request attributes
    request.setAttribute("value1", value1);
    ...redirect to the jsp
    in the JSP:
    get the wanted attributes:
    String value1=(String)request.getAttribute("value1");To learn how to parse a xml file, pay a look at this page, it explains how to read the XML document to build an object representation, and then how to navigate through this object to get the data
    http://labe.felk.cvut.cz/~xfaigl/mep/xml/java-xml.htm

  • Question about insert date value from xml file

    I want insert value into table from xml file. Every time I inserted value of date type into the table, I got the unpasable error message as following:
    oracle.xml.sql.OracleXMLSQLException: Exception 'java.text.ParseException:Unpars
    eable date: "2000-04-19 00:00:00.0"' encountered during processing ROW element
    Thanks for anyone that can fix my problem or give me any suggestion.
    email: [email protected]

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by matmnwx:
    I want insert value into table from xml file. Every time I inserted value of date type into the table, I got the unpasable error message as following:
    oracle.xml.sql.OracleXMLSQLException: Exception 'java.text.ParseException:Unpars
    eable date: "2000-04-19 00:00:00.0"' encountered during processing ROW element
    Thanks for anyone that can fix my problem or give me any suggestion.
    email: [email protected]<HR></BLOCKQUOTE>
    Use:
    OracleXMLSave sav = new OracleXMLSave(conn,tabName);
    sav.setDateFormat(<hier the date format in the XML-File>);

  • How to retrieve rows from .csv file

    Hi
    I need to retrieve rows from .csv file , anybody's kind support is greatly appreciated.
    Thanks in advance.
    Khiz_eng

    a .csv file is just a comma delimited text file. each row contains data separated by a comma. To read this information in, do as Hartmut suggested to your earlier post on this exact topic. "I would read that file with a FileReader / BufferedReader and parse each line with StringTokenizer. This would be quite the same like working through a result set." For more info on how to read text files, see any java book or browse through the i/o tutorial.
    Jamie

  • How to get the values from xml file to java combo box

    Hi frens,
    I am new to java and xml programming,
    Now, i want to have a code of getting the tag values from the xml file
    into the swing combo box of java front end.
    How can we do that?
    any help of code or tutorial or an ebook is a great help for me.
    Thank you,
    Karthik.
    Edited by: Karthik84 on Aug 27, 2008 1:49 AM
    Edited by: Karthik84 on Aug 27, 2008 11:29 PM

    look at this link
    http://www.stylusstudio.com/docs/v2006/d_help30.html
    I read sometime back that castor has a tool to do
    conversion. You might have a look into casto as well.

  • How to retrieve value from AIAInstallProperties.xml in AIA Flow.

    After PIP Developement, Installer team will build the OUI installer for the PIP.They will build the screens for our PIP based on the requirements we give them.We give them a list of properties that we need the installer to prompt for and then the installer will store the values entered by the user in AIAInstallProperties.xml file.When the code is written, these properties are used instead of hardcoding any machine names, usernames, passwords, etc. When the services are deployed the properties are replaced with the values in AIAInstallProperties.xml.
    How to retreive those values from AIAInstallProperties.xml file to your participating applications or any adapters in your code?
    When the services are deployed how the properties are getting replaced with the values in AIAInstallProperties.xml.?
    Can anyone explain the above two flow.
    Thanks in advance.

    Hi
    Prem Edwin's posting about AIAInstallProperties.xml is correct.
    Two points, the 11gR1 is a foundation pack only release, that is why the OUI is only built to collect FP related information. In the future, when PIPs arrive, new wizard steps will involve to collect PIP specific information during installation/deployment time.
    For your example of of getting a file location during installation, it would be effectively for your self-built PIPs. That is why the 11gR1 FP OUI would not support that.
    Also, there are only finite number of tokens can be detokenized from AIAInstallProperties.xml to composite.xml, if you were introducing a random new 'file path', I don't believe it would be replaced automatically by default in R1 time.
    Thanks!

  • How to parse and retrieve records from xml files into columns in Table

    Hi
    I attached the thing what i tried.
    Table to hold the XML COntent:
    create table xmlfile(xml_con sys.xmltype);
    Inserting Xml file content into the Above table:
    insert into xmlfile values(sys.xmltype.CreateXml('<Root><name>RAM</name><age>23</age></Root>'))
    SQL> select * from xmlfile;
    XML_CON
    <Root>
    <name>RAM</name>
    <age>23</age>
    </Root>
    SQL> select extractValue(xml_con, '/Root/name') content from xmlfile;
    CONTENT
    RAM
    This one works fine
    But if the file content is as below( contains MUltiple Records)
    insert into xmlfile values(sys.xmltype.CreateXml('<Root><Record><name>RAM</name><age>23</age></Record><Record><name>SAM</name><age>23</age></Record></Root>'))
    SQL> select extractValue(xml_con, '/Root/Record/name') content from xmlfile;
    ERROR at line 1:
    ORA-19025: EXTRACTVALUE returns value of only one node
    Can anyone help me 4 this issue-How to extract multiple records from the XML file inthis manner(from PL/SQL without using JAVA)
    OR
    If there is anyother way to do this please tell me?

    SQL> SELECT EXTRACTVALUE (COLUMN_VALUE, '//name') NAME,
           EXTRACTVALUE (COLUMN_VALUE, '//age') age
      FROM TABLE
              (XMLSEQUENCE
                  (EXTRACT
                      (XMLTYPE
                          ('<Root>
                              <Record>
                                <name>RAM</name>
                                <age>23</age>
                              </Record>
                              <Record>
                                <name>SAM</name>
                                <age>23</age>
                              </Record>
                            </Root>'
                       '/Root/Record'
    NAME       AGE      
    RAM        23       
    SAM        23       
    2 rows selected.

Maybe you are looking for