Traversing complex xml File in android - java

I have a xml file that is on this link
http://nchc.dl.sourceforge.net/project/trialxml/options.xml
I have downloaded and parsed it successfully and also made a dynamic UI, but I have not used any of the predefined functions like getFirstChild(), getNextSibling() which makes my parser incompatible of parsing complex XML files having around 6-7 levels of menus.
Please help how to traverse a XML file,and dynamically create a UI.

Try using DOM parser, to parse your xml document
See this link for further details:
http://tutorials.jenkov.com/java-xml/dom.html

Related

Reading an XSD file to get all the elements and corresponding attributes in Java

My requirement is to read an XSD file and to get all its elements with corresponding attributes in java. I've been trying to convert my XSD file to a sample XML file as parsing an XML file to get all it's elements and attributes is easy. But so far I've been unable to find a good enough tool in java to programmatically convert my XSD to sample XML.
Is there any free and good java code available to convert an XSD to its sample XML?
Or else what is the way I can read all the elements and attributes that a sample XML would contain directly from the XSD file?
Thanks in advance!
Processing a raw XSD document as XML is quite tricky except in very simple cases.
Alternatives are:
(a) use an API for accessing a compiled schema (for example, there is such an API in Xerces)
(b) Saxon's schema processor can output an XML representation of the compiled schema, which is much easier to process than the raw XSD documents (for example, it combines everything into one document, and presents the relationship of elements to types in a uniform way).
The xsd format is perfectly valid XML, so you can parse an XML schema file with any xml parser.
Check this related post to get some code samples and ideas:
Java API to parse XSD schema file
Not sure if this solves the problem. I have similar requirement of accessing elements and attributes of xsd. Using Eclipse, the solution to create XML out of xsd is quite easy. I have a dynamic web project created and put my xsd in webcontent. Right click on XSD and there is option called 'Generate'. It shows 2 options to generate XML or JAXB classes. On clicking Generate XML, XML file is created from XSD. I hope you were looking for this solution.
There is a tool in java to convert my XSD to sample XML. You need to add jaxb-xjc (executable jar file) in the build path of your project.Once you are done with it just put the .xsd file in src, right click on it and find 'Generate' option, you can now find XML and Jaxb classes against 'Generate' option, Select Xml and get your XML file generated from .xsd.

XML Parser for editing XML content in Java

I'm new to XML Development. I was wondering if anyone on here knows what's the best XML parser to use for adding contents into an XML document in Java?
If you're adding or modifying contents, I would look at a DOM parser. dom4j comes to mind.

Java api for pdf

Which APIs in java help in extracting table metadata from a pdf, and presenting that table in a web page?
The result should be that when the source of page is viewed it will show the html code of that table.
Itext is usefull in this context
http://itextpdf.com/
I assume that, you need a PDF library for Java.
PDFBox is one of the popular libraries created to PDF manipulation and I think it is worth to look at it.
try The Metadata Extract Tool which extracts metadata from specific file types including PDF. Then you can parse the xml output with any Java XML parser. Once you're able to parse it, elements can be easily laid down in your view page.

How to get data from XSD file

I have an XML schema file. I want to use Java to open this file, find all elements, extract their names, and write them to a text file. I have tried various libraries, but I could not get this to work. Please suggest any libraries or other methods that will work.
XSD files are XML files so you can use any suitable XML processing library to parse it.
I don't think you'll find a library that exists for your purpose, you'll have to write one yourself. The XSD is simply an XML file that conform to the schema:
Traverse the file as normal using DOM or SAX or whatever your preference is.
I assume you are looking for the information conveyed by the XML Schema. I would recommend you the XSOM library, it takes away dealing with the XML itself; nonetheless, a basic understanding of what can be described by an XSD is most likely required.
Follow the user guide, there are some examples showing how to move towards what you need.

using jpedal to extract hyperlinks from html? --java

JPedal library in java is usually used to convert pdf to XML or HTML. However, I needed to know if we could extract data from HTML5 document and save it to XML using JPedal library API?
Is there any other possible alternative to this?
Also , I am trying to parse HTML5 document using Java and store it in XML. are there any good solutions to find just specific tags and render an XML out of them?
Please do let me know . Thank you.
There are a number of Java HTML parsers out there, but I recommend using the HTML5 parser from validator.nu available for download from here: http://about.validator.nu/htmlparser/.
Written to use the HTML5 parser algorithm by one of the main protagonists of HTML5, Henri Sivonen of Mozilla, you won't find a more reliable HTML parser and it creates a true DOM that can be manipulated using standard XML tools and queried for hyperlinks using XPath. There are examples of how to use XSLT transformations with it and how to get an XML serialization of the created DOM.

Categories

Resources