Jump to content

How to use XML in a report?


brieweb

Recommended Posts

I am trying to use XML in a report, but whenever I add an XML source, I can't see any of the fields when using the report wizard. Take the following xml sample. How do I add it as a datasource to use in a report? Do I have to use an XPATH expression? What would the XPATH be if I do?

Thanks,

brian

File is c:\data\story.xml

<?xml version="1.0"?><story>  <storyinfo>    <author>John Fleck</author>    <datewritten>June 2, 2002</datewritten>    <keyword>example keyword</keyword>  </storyinfo>  <body>    <headline>This is the headline</headline>    <para>This is the body text.</para>  </body></story>[/code]
Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

I'm very new to iReport, but I answered a similar question at:

 

http://jasperforge.org/plugins/espforum/view.php?group_id=102&forumid=103&topicid=75422

 

I'll paste an excerpt of the text below in case the link is stripped out by the forum software.

 

I think in your case you'd specify the data source query as "/story" and the report query as "*".

 

- Keith

 

---- Excerpt: ----

In the data source text field labeled "Create data source using this expression", I specified /outerElementName (where "outerElementName" is whatever your outer element name is). Then in the report query dialog I specified XPath as the query language, and specified * as the query string.

I have a subreport with repeating elements. For that one, I got it to work by specifying /outerElementName/repeatingElementName in the data source, and outerElementName/repeatingElementName (notice the absence of the leading slash) for the report query.

This worked for me, but I'd be curious to know if there's a better way.

 

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...