3

I want to parse xml file in spring project. Can anyone provide direction for this?

This xml file will be used to load various fields which are required to be validated for each jsf page.

I want to use this xml to be read through document build factory or any generic function present in the spring

DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(fXmlFile);

I want to validate a page for specific values which are defined in this xml. So I need to parse this xml file as we do in simple java program using DocumentBuilderFactory

8
  • do you want to parse a generic XML file, or do you want Spring to read your XML configuration file and instantiate your beans? Commented May 17, 2011 at 9:08
  • you want to parse any .xml file, or you want to parse the spring configuration xml files? Commented May 17, 2011 at 9:08
  • Or a Java properties.xml file? Commented May 17, 2011 at 9:10
  • @Bozho i want to parse any xml file Commented May 17, 2011 at 9:15
  • 1
    What kind of vague question is this? Just stopped short of downvoting. Please can you explain your question more clearly? Commented May 17, 2011 at 9:19

1 Answer 1

3

The question is much too vague, many different scenarios are possible.

However, I thing you should take a look at the Chapter 14. Marshalling XML using O/X Mappers from the Spring reference. Perhaps you will find the answer there.


Ah, more info in the Question. So the XML contains properties, although it is not in the Java properties XML format.

OK, then I guess I'd write a BeanPostProcessor that uses Commons / Config under the hood to read the properties from XML. You should probably copy what the PropertyPlaceholderConfigurer does, to a certain extent.

Sign up to request clarification or add additional context in comments.

1 Comment

i have new question on AspectJ

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.