Question

I am facing a parsing problem with xml generated in C. I need to parse Xml like below to Java objects. Is there any elegant way how to deal with this?

<?xml version="1.0" encoding="utf-8"?>
<methodResponse>
  <params>
    <param>
      <value>
        <struct>
          <member>
            <name>resps</name>
            <value>
              <array>
                <data> 
                  <member>
                    <name>id</name>
                    <value>
                      <int>10</int>
                    </value>
                  </member> 
                  <member>
                    <name>name</name>
                    <value>
                      <string>Test Name</string>
                    </value>
                  </member>
                </data>
              </array>
            </value>
          </member> 
        </struct>
      </value>
    </param>
  </params>
</methodResponse>
Was it helpful?

Solution

You can use jaxb api. All you need is a xsd document for your xml. Then jaxb will generate the Java classes that you can use in your program.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top