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.
Similar Messages
-
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.
rituhi 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 -
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?
ThanksThese 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
NagarajuThis 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 -
Passing Parameters from XML file to Java Application
Can any one help me to know the way of passing values from XML file to Java Application..
Thanx in advanceWith the Processing Instructions <?name pidata?>
Get the Nodes in a Document.
Node node;
if(node.getNodeType()==Node.PROCESSING_INSTRUCTION_NODE)
//String param=node.getData(); -
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 can (parse) i use XML file with missing EndTag
hi,
i have an application which writes an "XML file".
another application should read that XML file, build an DOM and
access the nodes with xpath.
my problem. if the first application is not finished there are tags
missing. e.g. </xml>. but the seconds application cannot wait until the first application finishes it task.
if i now read the XML file the parser cannot load it because the end tags are missing.
my question:
how can i deactivate the check or how can i read the XML file and access it via XPath (my application is using at the moment XPath to access the nodes and i dont want to change that)
as parser i am using XERCES
alexAs far as I know, you can't do this - xml must be well formed (this is sort of a bedrock of xml). There may be some work around's, but I'm not aware of any - and they would most likely be hacks.
-
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,
NareshDan_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 delete a perticular node from xml file using java code
Hii All,
Now i am trying to delete a perticular node from xml file.Like...
XML file:
<Licence>
<SERVER>
<was id="1">1</was>
<was id="2">2</was>
</SERVER>
</LICENCE>
I am working in messaging service using JABBER framework with whiteboard facility.
Here Some commands i have created to add,modify,delete nodes from xml file.They Are
1.If u want to add a new node then.
create Licence.SERVER <ss id="3">ddd</ss> lic.xml
(here u want to add a new node called "ss" under Licence.SERVER.
And lic.xml is tyhe xml file name where it was saved.
2.If u want to delete a node(Suppose <was id="1">),then the command should be
delete Licence.SERVER.was:id='"1" lic.xml
A problem arises that here it find two was attributes.And it delete the last was attribute,not the requested node.
PLEASE HELP ME IN SOLVING THIS CODE..
------------------------------------Looks like you clicked on "Post" before you pasted in the code you were talking about.
-
Couldn't parse image from XML file using NSXMLParser
Hi all, Since i am newbie to developing iPhone application, i have problem in parsing XML data.
I use the following code for parsing XML file, this is RootViewController.h file
#import <UIKit/UIKit.h>
#import "SlideMenuView.h"
#define kNameValueTag 1
#define kColorValueTag 2
#define kSwitchTag 100
@class DetailViewController;
@interface RootViewController : UIViewController <UITableViewDataSource, UITableViewDelegate> {
DetailViewController *detailViewController;
UITableView *myTable;
UIActivityIndicatorView *activityIndicator;
UIButton *btn;
CGSize cellSize;
NSXMLParser *rssParser;
NSMutableArray *stories;
NSMutableDictionary *item;
NSString *currentElement;
NSMutableString *currentTitle, *currentDate, *currentSummary, *currentLink, *currentImage;
SlideMenuView *slideMenu;
NSMutableArray *buttonArray;
UIButton *rubic;
UIButton *buurt;
UIButton *beeld;
UILabel *lbl;
NSString *url;
@property (nonatomic, retain) UITableView *myTable;
@property (nonatomic, retain) DetailViewController *detailViewController;
@property (nonatomic, retain) SlideMenuView *slideMenu;
@property (nonatomic, retain) UIButton *btn;
@property (nonatomic, retain) NSMutableArray *buttonArray;
@property (nonatomic, retain) UIButton *rubic;
@property (nonatomic, retain) UIButton *buurt;
@property (nonatomic, retain) UIButton *beeld;
@property (nonatomic, retain) UILabel *lbl;
@end
below is the RootViewController.m file,
#import <Foundation/Foundation.h>
#import "RootViewController.h"
#import "DetailViewController.h"
#import "SlideMenuView.h"
@implementation RootViewController
@synthesize rubic, buurt, beeld, detailViewController, myTable, btn, buttonArray, slideMenu, lbl;
- (void)parseXMLFileAtURL:(NSString *)URL {
stories = [[NSMutableArray alloc] init];
//you must then convert the path to a proper NSURL or it won't work
NSURL *xmlURL = [NSURL URLWithString:URL];
// here, for some reason you have to use NSClassFromString when trying to alloc NSXMLParser, otherwise you will get an object not found error
// this may be necessary only for the toolchain
rssParser = [[NSXMLParser alloc] initWithContentsOfURL:xmlURL];
// Set self as the delegate of the parser so that it will receive the parser delegate methods callbacks.
[rssParser setDelegate:self];
// Depending on the XML document you're parsing, you may want to enable these features of NSXMLParser.
[rssParser setShouldProcessNamespaces:NO];
[rssParser setShouldReportNamespacePrefixes:NO];
[rssParser setShouldResolveExternalEntities:NO];
[rssParser parse];
- (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError {
NSString * errorString = [NSString stringWithFormat:@"Unable to download story feed from web site (Error code %i )", [parseError code]];
NSLog(@"error parsing XML: %@", errorString);
UIAlertView * errorAlert = [[UIAlertView alloc] initWithTitle:@"Error loading content" message:errorString delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[errorAlert show];
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{
//NSLog(@"found this element: %@", elementName);
currentElement = [elementName copy];
if ([elementName isEqualToString:@"item"]) {
// clear out our story item caches...
item = [[NSMutableDictionary alloc] init];
currentTitle = [[NSMutableString alloc] init];
currentDate = [[NSMutableString alloc] init];
currentSummary = [[NSMutableString alloc] init];
currentLink = [[NSMutableString alloc] init];
currentImage = [[NSMutableString alloc] init];
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName{
//NSLog(@"ended element: %@", elementName);
if ([elementName isEqualToString:@"item"]) {
// save values to an item, then store that item into the array...
[item setObject:currentTitle forKey:@"title"];
[item setObject:currentSummary forKey:@"summary"];
[item setObject:currentDate forKey:@"date"];
[item setObject:currentImage forKey:@"enclosure"];
[stories addObject:[item copy]];
NSLog(@"adding story: %@", currentTitle);
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{
//NSLog(@"found characters: %@", string);
// save the characters for the current item...
if ([currentElement isEqualToString:@"title"]) {
[currentTitle appendString:string];
} else if ([currentElement isEqualToString:@"description"]) {
[currentSummary appendString:string];
} else if ([currentElement isEqualToString:@"pubDate"]) {
[currentDate appendString:string];
} else if ([currentElement isEqualToString:@"enclosure"]) {
[currentImage appendString:string];
- (void)parserDidEndDocument:(NSXMLParser *)parser {
[activityIndicator stopAnimating];
[activityIndicator removeFromSuperview];
NSLog(@"all done!");
NSLog(@"stories array has %d items", [stories count]);
[myTable reloadData];
- (void)loadView {
//self.title = @"GVA_iPhone";
//UIImage *img = [UIImage imageNamed: @"gva_v2.1.png"];
CGRect frame = [[UIScreen mainScreen] bounds];
UIView *aView = [[UIView alloc] initWithFrame:frame];
aView.backgroundColor = [UIColor grayColor];
self.view = aView;
[aView release];
lbl = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 33.0, 320.0, 30.0)];
lbl.backgroundColor = [UIColor colorWithRed:21.0/255.0 green:113.0/255.0 blue:194.0/255.0 alpha:1.0];
lbl.textColor = [UIColor whiteColor];
lbl.font = [UIFont boldSystemFontOfSize:18.0];
[self.view addSubview:lbl];
[lbl release];
buttonArray = [[NSMutableArray alloc] init];
for(int i = 1; i < 4; i++)
// Rounded rect is nice
//UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
// Give the buttons a width of 100 and a height of 30. The slide menu will take care of positioning the buttons.
// If you don't know that 100 will be enough, use my function to calculate the length of a string. You find it on my blog.
[btn setFrame:CGRectMake(0.0f,3.0f, 120.0f, 30.0f)];
switch(i){
case 1:
[btn setTitle:[NSString stringWithFormat:@" Snel", i+1] forState:UIControlStateNormal];
[btn setBackgroundImage:[UIImage imageNamed:@"topbg02.png"] forState:UIControlStateNormal];
lbl.text = @" Snel";
[btn addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
[buttonArray addObject:btn];
break;
case 2:
[btn setTitle:[NSString stringWithFormat:@" Binnenland", i+1] forState:UIControlStateNormal];
[btn setBackgroundImage:[UIImage imageNamed:@"topbg02.png"] forState:UIControlStateNormal];
[btn addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
[buttonArray addObject:btn];
break;
case 3:
[btn setTitle:[NSString stringWithFormat:@" Buitenland", i+1] forState:UIControlStateNormal];
[btn setBackgroundImage:[UIImage imageNamed:@"topbg02.png"] forState:UIControlStateNormal];
[btn addTarget:self action:@selector(buttonTouched:) forControlEvents:UIControlEventTouchUpInside];
[buttonArray addObject:btn];
break;
[btn release];
slideMenu = [[SlideMenuView alloc]initWithFrameColorAndButtons:CGRectMake(0.0, 3.0, 330.0, 30.0) backgroundColor:[UIColor blackColor] buttons:buttonArray];
[self.view addSubview:slideMenu];
UITableView *aTableView = [[UITableView alloc] initWithFrame:CGRectMake(0.0, 63.0, 320.0, 310.0)];
aTableView.dataSource = self;
aTableView.delegate = self;
aTableView.rowHeight = 120;
self.myTable = aTableView;
[aTableView release];
[self.view addSubview:myTable];
rubic = [[UIButton alloc]initWithFrame:CGRectMake(0.0, 370.0, 105.0, 50.0)];
[rubic setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[rubic setBackgroundImage:[UIImage imageNamed:@"MOUSEOVER.png"] forState:UIControlStateNormal];
[rubic addTarget:self action:@selector(buttonBinn:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:rubic];
UILabel *lblRub = [[UILabel alloc]initWithFrame:CGRectMake(10.0, 385.0, 45.0, 12.0)];
lblRub.text = @"Rubriek";
lblRub.font = [UIFont boldSystemFontOfSize:11.0];
lblRub.backgroundColor = [UIColor clearColor];
lblRub.textColor = [UIColor whiteColor];
[self.view addSubview:lblRub];
UIImageView *imgCat = [[UIImageView alloc] initWithFrame:CGRectMake(58.0, 375.0, 39.0, 36.0)];
imgCat.image = [UIImage imageNamed:@"category_icon.png"];
[self.view addSubview:imgCat];
buurt = [[UIButton alloc] initWithFrame:CGRectMake(105.0, 370.0, 108.0, 50.0)];
[buurt setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[buurt setBackgroundImage:[UIImage imageNamed:@"bottombg01.png"] forState:UIControlStateNormal];
[buurt addTarget:self action:@selector(buttonBuurt:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:buurt];
UILabel *lblGlo = [[UILabel alloc]initWithFrame:CGRectMake(112.0, 385.0, 59.0, 12.0)];
lblGlo.text = @"In de Buurt";
lblGlo.font = [UIFont boldSystemFontOfSize:11.0];
lblGlo.backgroundColor = [UIColor clearColor];
lblGlo.textColor = [UIColor whiteColor];
[self.view addSubview:lblGlo];
UIImageView *imgGlo = [[UIImageView alloc] initWithFrame:CGRectMake(173.0, 375.0, 39.0, 36.0)];
imgGlo.image = [UIImage imageNamed:@"globe_icon.png"];
[self.view addSubview:imgGlo];
beeld = [[UIButton alloc]initWithFrame:CGRectMake(213.0, 370.0, 108.0, 50.0)];
[beeld setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[beeld setBackgroundImage:[UIImage imageNamed:@"bottombg01.png"] forState:UIControlStateNormal];
[beeld addTarget:self action:@selector(buttonBeeld:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:beeld];
UILabel *lblCam = [[UILabel alloc]initWithFrame:CGRectMake(228.0, 385.0, 45.0, 12.0)];
lblCam.text = @"In Beeld";
lblCam.font = [UIFont boldSystemFontOfSize:11.0];
lblCam.backgroundColor = [UIColor clearColor];
lblCam.textColor = [UIColor whiteColor];
[self.view addSubview:lblCam];
UIImageView *imgCam = [[UIImageView alloc] initWithFrame:CGRectMake(276.0, 375.0, 39.0, 36.0)];
imgCam.image = [UIImage imageNamed:@"camera_icon.png"];
[self.view addSubview:imgCam];
if([stories count] == 0) {
[self parseXMLFileAtURL:@"http://iphone.concentra.exuvis.com/feed/rss/article/2/binnenland.xml"];
cellSize = CGSizeMake([myTable bounds].size.width,60);
- (IBAction)buttonPressed:(id)sender {
lbl.text = ((UIButton*)sender).currentTitle;
- (IBAction)buttonClicked:(id)sender {
lbl.text = ((UIButton*)sender).currentTitle;
- (IBAction)buttonTouched:(id)sender {
lbl.text = ((UIButton*)sender).currentTitle;
-(void)buttonBinn:(id)sender
[rubic setBackgroundImage:[UIImage imageNamed:@"MOUSEOVER.png"] forState:UIControlStateNormal];
[buurt setBackgroundImage:[UIImage imageNamed:@"bottombg01.png"] forState:UIControlStateNormal];
[beeld setBackgroundImage:[UIImage imageNamed:@"bottombg01.png"] forState:UIControlStateNormal];
-(void)buttonBuurt:(id)sender
[buurt setBackgroundImage:[UIImage imageNamed:@"MOUSEOVER.png"] forState:UIControlStateNormal];
[beeld setBackgroundImage:[UIImage imageNamed:@"bottombg01.png"] forState:UIControlStateNormal];
[rubic setBackgroundImage:[UIImage imageNamed:@"bottombg01.png"] forState:UIControlStateNormal];
-(void)buttonBeeld:(id)sender
[beeld setBackgroundImage:[UIImage imageNamed:@"MOUSEOVER.png"] forState:UIControlStateNormal];
[rubic setBackgroundImage:[UIImage imageNamed:@"bottombg01.png"] forState:UIControlStateNormal];
[buurt setBackgroundImage:[UIImage imageNamed:@"bottombg01.png"] forState:UIControlStateNormal];
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
// Release anything that's not essential, such as cached data
- (void)dealloc {
[myTable release];
[detailViewController release];
[super dealloc];
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return [stories count];
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"GVAiPhone"];
if (cell == nil) {
//CGRect cellFrame = CGRectMake(0, 0, 300, 65);
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"GVAiPhone"] autorelease];
//cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
//cell.accessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"arrow_icon.png"]];
CGRect nameValueRect = CGRectMake(5, 5, 275, 35);
UILabel *nameValue = [[UILabel alloc] initWithFrame:nameValueRect];
nameValue.tag = kNameValueTag;
nameValue.font = [UIFont fontWithName:@"Arial" size:15.0];
nameValue.lineBreakMode = UILineBreakModeWordWrap;
nameValue.numberOfLines = 2;
[cell.contentView addSubview:nameValue];
[nameValue release];
CGRect colorValueRect = CGRectMake(5, 38, 275, 65);
UILabel *colorValue = [[UILabel alloc] initWithFrame:colorValueRect];
colorValue.tag = kColorValueTag;
colorValue.font = [UIFont fontWithName:@"Arial" size:11.0];
colorValue.textColor = [UIColor colorWithRed:130.0/255.0 green:135.0/255.0 blue:139.0/255.0 alpha:1.0];
colorValue.lineBreakMode = UILineBreakModeWordWrap;
colorValue.textAlignment = UITextAlignmentLeft;
colorValue.numberOfLines = 6;
[cell.contentView addSubview:colorValue];
[colorValue release];
// Set up the cell
//cell.text = [theSimpsons objectAtIndex:indexPath.row];
//cell.hidesAccessoryWhenEditing = YES;
NSUInteger storyIndex = [indexPath row];
NSDictionary *rowData = [stories objectAtIndex:storyIndex];
UILabel *name = (UILabel *)[cell.contentView viewWithTag:kNameValueTag];
name.text = [rowData objectForKey:@"title"];
//name.lineBreakMode;
//UIImage *image =[UIImage imageNamed: currentImage];imageWithContentsOfFile
//image.size.width = 50;
//iimage.size.height = 50;
//cell.image = [UIImage imageNamed:currentImage];
cell.accessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"arrow_icon.png"]];
UILabel *color = (UILabel *)[cell.contentView viewWithTag:kColorValueTag];
color.text = [rowData objectForKey:@"summary"];
return cell;
@end
- here the actual problem is the xml node <enclosure> contains images but in using the method "didEndElement" , it doesn't parse into the <enclosure> node. ya so please help me in parsing and getting the image.
Waiting for your help !!
-SathiyaHi, how did you solve your problem in detail. I'm having the same problem with this rss-feed: www.spiegel.de/index.rss
I cannot parse the url of the images. I'm looking forward to your answer. -
How to get attribute from xml file
I managed to grab all the info from xml, except the "url" attribute in <image type="poster" url="" size="mid" .../>. Any ideas?
import java.io.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.net.*;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
public class XmlParser {
ArrayList<Movie> myMovies;
Document dom;
public XmlParser(){
//create a list to hold the movie objects
myMovies = new ArrayList<Movie>();
public void runExample(String adr, String tagName) {
parseXmlFile(adr);
parseDocument(tagName);
printData();
private void parseXmlFile(String adr){
//get the factory
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
try {
//Using factory get an instance of document builder
DocumentBuilder db = dbf.newDocumentBuilder();
//parse using builder to get DOM representation of the XML file
URL xmlUrl = new URL(adr);
InputStream in = xmlUrl.openStream();
dom = db.parse(in);
}catch(ParserConfigurationException pce) {
pce.printStackTrace();
}catch(SAXException se) {
se.printStackTrace();
}catch(IOException ioe) {
ioe.printStackTrace();
private void parseDocument(String tagName){
//get the root elememt
Element docEle = dom.getDocumentElement();
//get a nodelist of <movie> elements
NodeList nl = docEle.getElementsByTagName(tagName);
if(nl != null && nl.getLength() > 0) {
for(int i = 0 ; i < nl.getLength();i++) {
//get the movie element
Element el = (Element)nl.item(i);
//get the Movie object
Movie mov = getMovie(el);
//add it to list
myMovies.add(mov);
* I take an movie element and read the values in, create
* an Movie object and return it
* @param movE
* @return
private Movie getMovie(Element movE) {
String title = getTextValue(movE, "original_name");
String year = getTextValue(movE, "released");
String imdbId = getTextValue(movE, "imdb_id");
double score = getDoubleValue(movE, "score");
String overview = getTextValue(movE, "overview");
String poster = movE.getAttribute("url");
Movie mov = new Movie(title, year, imdbId, score, overview, poster);
return mov;
private String getTextValue(Element ele, String tagName) {
String textVal = null;
NodeList nl = ele.getElementsByTagName(tagName);
if(nl != null && nl.getLength() > 0) {
Element el = (Element)nl.item(0);
textVal = el.getFirstChild().getNodeValue();
return textVal;
* Calls getTextValue and returns a int value
* @param ele
* @param tagName
* @return int
private int getIntValue(Element ele, String tagName) {
//in production application you would catch the exception
return Integer.parseInt(getTextValue(ele, tagName));
* Calls getTextValue and returns a double value
* @param ele
* @param tagName
* @return double
private double getDoubleValue(Element ele, String tagName) {
return Double.parseDouble(getTextValue(ele, tagName));
* Iterate through the list and print the
* content to console
private void printData(){
System.out.println("Total Movies: " + myMovies.size());
Iterator it = myMovies.iterator();
while(it.hasNext()) {
System.out.println(it.next().toString());
public static void main(String[] args){
//create an instance
XmlParser xp = new XmlParser();
//call run example
xp.runExample("http://api.themoviedb.org/2.1/Movie.search/en/xml/apikey/Fight+Club+1999", "movie");
}Here is the example xml file I used
<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">
<opensearch:Query searchTerms="Fight Club 1999"/>
<opensearch:totalResults>1</opensearch:totalResults>
<movies>
<movie>
<score>8.383284</score>
<popularity>3</popularity>
<translated>true</translated>
<adult>false</adult>
<language>en</language>
<original_name>Fight Club</original_name>
<name>Fight Club</name>
<alternative_name>El Club de la Lucha</alternative_name>
<type>movie</type>
<id>550</id>
<imdb_id>tt0137523</imdb_id>
<url>http://www.themoviedb.org/movie/550</url>
<votes>62</votes>
<rating>8.4</rating>
<certification></certification>
<overview>A lonely, isolated thirty-something young professional seeks an escape from his mundane existence with the help of a devious soap salesman. They find their release from the prison of reality through underground fight clubs, where men can be what the world now denies them. Their boxing matches and harmless pranks soon lead to an out-of-control spiral towards oblivion.</overview>
<released>1999-09-16</released>
<images>
<image type="poster" url="http://hwcdn.themoviedb.org/posters/f75/4bc908ab017a3c57fe002f75/fight-club-original.jpg" size="original" width="1000" height="1500" id="4bc908ab017a3c57fe002f75"/>
<image type="poster" url="http://hwcdn.themoviedb.org/posters/f75/4bc908ab017a3c57fe002f75/fight-club-mid.jpg" size="mid" width="500" height="750" id="4bc908ab017a3c57fe002f75"/>
<image type="poster" url="http://hwcdn.themoviedb.org/posters/f75/4bc908ab017a3c57fe002f75/fight-club-cover.jpg" size="cover" width="185" height="278" id="4bc908ab017a3c57fe002f75"/>
<image type="poster" url="http://hwcdn.themoviedb.org/posters/f75/4bc908ab017a3c57fe002f75/fight-club-thumb.jpg" size="thumb" width="92" height="138" id="4bc908ab017a3c57fe002f75"/>
<image type="backdrop" url="http://hwcdn.themoviedb.org/backdrops/f71/4bc908ab017a3c57fe002f71/fight-club-original.jpg" size="original" width="1280" height="720" id="4bc908ab017a3c57fe002f71"/>
<image type="backdrop" url="http://hwcdn.themoviedb.org/backdrops/f71/4bc908ab017a3c57fe002f71/fight-club-poster.jpg" size="poster" width="780" height="439" id="4bc908ab017a3c57fe002f71"/>
<image type="backdrop" url="http://hwcdn.themoviedb.org/backdrops/f71/4bc908ab017a3c57fe002f71/fight-club-thumb.jpg" size="thumb" width="300" height="169" id="4bc908ab017a3c57fe002f71"/>
</images>
<version>73</version>
<last_modified_at>2010-09-11 14:33:06</last_modified_at>
</movie>
</movies>
</OpenSearchDescription>pvujic wrote:
Thanks, but how can I "fetch" the url from the image element?You've got to first get to the image element. But based on what you've posted though, with a little more coding, you should be able to succeed. Just give it a try! :) -
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 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 PMlook 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 extract data from xml file in owb 10.2?
I have to load data from an xml file into a relational table , may i know how to do it in owb 10.2.
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 -
How to add bookmarks from .xml file?
I switched from a PC to an iMac and i'm trying to set up the Safari browser. I was using MSN explorer as my default. I saved the .xml file where all my bookmarks were stored. Is there a way I can import the .xml file so all my bookmarks can load?
hi,
check out the following links
Check this blog to extract from XML:
/people/kamaljeet.kharbanda/blog/2005/09/16/xi-bi-integration
http://help.sap.com/saphelp_nw04/helpdata/en/fe/65d03b3f34d172e10000000a11402f/frameset.htm
Check thi link for Extract from any DB:
http://help.sap.com/saphelp_nw04s/helpdata/en/58/54f9c1562d104c9465dabd816f3f24/content.htm
regards
harikrishna N
Maybe you are looking for
-
IPhoto library won't display, "Loading Photos" endlessly
Iphoto won't display the library, it shows the loading photos graphic endlessly. Tried deleting all relevant metadata (files in iphoto library folder and library>preferences) and repairing disk permissions, to no effect. Did not move or rename iphoto
-
Hi, We have a payment program config issue. We have around 14 company codes. For all the company codes we have only one paying company code 2000. Now for a company code 1000, we want to pay some project related expenses by the particular company code
-
Can't view movie trailers with iTunes 7.1
I am trying to view trailers. I click the "view trailer" button, a screen appears telling me it's loading, it goes and goes for awhile. Then, it appears that the screen changes for a split second and has a preview window in it, but then instantly rev
-
Does Adobe Reader for Android have the Flash Player Runtime
I have a PDF document that I generate which contains an embedded Flex application. It works fine with the desktop version of PDF reader. However. It doesn't appear that PDF reader for Android contains the Flash Player runtime. Can someone from Adobe
-
try URL temp = new URL(urls); BufferedReader bufRed = new BufferedReader(new InputStreamReader(temp.openStream())); String stringBuf = ""; while(!stringBuf.equals(null)) stringBuf = bufRed.readLine(); StringTok