0

I have 2 XML file . In one XML file is the form which contains x and y coordinate values . In second XML file contains all the functioning/operation related to first XML which gives an output as an graph image .

I need to know how can I read the function XML file specially for functioning in java program on button click ? I know to parse , but just normal parsing will work for the operation. What libraries do I have to pass for this ?

The functioning part is already there in XML . I just need to call it to show output.

part of form XML which will be used to save x and y coordinate:-

<cont format="%9.2f" hotlink="true" name="cont_2" refvar="gud/_ZSFR[29]" type="float" width="20" xpos="545" ypos="454">
            <PROPERTY min="0"/>
            <PROPERTY max="5000"/>
        </cont>

part of function xml file which will actually do operation of generating image by passing those form xml x and y values:-

<function name="string.length" return="filenamelength">file_name</function>
    <IF>
        <CONDITION>filenamelength>=1</CONDITION>
        <THEN>
            <op>new1content=new1content+_T"\\nR250="+_F%.3f"gud/_ZSFR[29]"</op>
            <op>new1content=new1content+_T"\\nR251="+_F%.3f"gud/_ZSFR[28]"</op>
<function name="doc.exist" return="mpf1ok">_T"\mpf\1.mpf" </function>
2
  • 1
    what have you done till now? share here please Commented Feb 2, 2017 at 6:26
  • @SeeKing Not yet in terms of getting image from functioning xml file. I did just to parse form xml file from java to fill x and y coordinates . The coordinate functionality of generating image is in function xml file . Which I am unable to understand how to use it in java to read entire function and the library tht will do the functioning in java . Commented Feb 2, 2017 at 7:11

2 Answers 2

1

There are two kinds of Libraries in java for parsing XML files. Streaming based and Tree based. If you just need to parse XML (Not concerned with generating XML) you can use Streaming API's are memory efficient. Stax is recommended in your case.

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

3 Comments

If I simply parse that XML file , will it create Image on the java file as the functioning of that XML file include creation of image ?
What kind of image?
Not, it will not directly create the image. When you are reading XML file, you need to decide on content you retrieved from XML file.
1

It sounds like what you need is a combination of:

  • javax.xml.parsers...
  • org.w3c.dom....

there is a good tutorial on extracting data from XML here at tutorialspoint their basic example shows the use of a method called Document.getElementByTagName(String tagName) which returns an Element object. depending on how specific your element is you can also check attributes using:

  • Element.getAttribute(String attrName)
  • Element.hasAttribute(String attrName)

this should allow you to pinpoint the tag that you need after which you can use the methods shown in the tutorial to extract the content of the tags.

Another simple XML tutorial in Java

3 Comments

Yes , but not exactly this I want . I need to call libraries to do the function in java. this is the line doing the entire functioning <op>new1content=new1content+_T"\\nR250="+_F%.3f"gud/_ZSFR[29]"</op>
unless there is some framework i am unaware of that does this, XML is simply a markup language used for describing data, not for performing computation. Are you saying that you want your "functioning" lines to be an API call of some description, if so then you might want to have a look at JAXB which allows you to marshall/unmarshall XML into/from data objects that you can then manipulate in java. Either way the XML is only data, any generation of images will need to be done in java using the data provided in the XML, unless you embed the base64 image data directly into the XML.
That's valuable info . The thing is that data is in x and y coordinate and rest creation of graph(not exactly image) is in functioning xml . I am looking to it.

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.