B4J Question How can you recursively call over Parse_EndElement with jXmlSax?

TorontoJim

Member
Licensed User
Longtime User
I'm having trouble importing XML. I have the app writing the XML, and it validates when I check it (http://www.xmlvalidation.com/)

I've looked at the documentation for jXmlSax, as well as forum posts and @rwblinn tutorials. However, I can't figure out how to read this recursively, which I was able to do with JSON input. I can't hard code a set number of loops, because in the end application, the user will be creating TreeView items on the fly. I've tested the app with as many as 25 levels, only stopping there because I got bored.

So I need a way to recursively iterate when xmlParser_EndElement is called. However, recursively may be the wrong idea. I'm open to going in a new direction as to how to do this. It's the last piece of the puzzle and of course, I'm beating my head on the desk.

I don't have code to post, because I can't figure out how to get it even to the point of failing.

Below, however, is the structure of the XML content that was exported from a tree view.

I just need someone to point me in the right direction.

B4X:
<?xml version="1.0" encoding="UTF-8"?>
<root>
  <Topic>
    <Text>Item #1</Text>
    <Children>
      <ChildTopic>
        <Text>Child #1</Text>
        <Children>
          <ChildTopic>
            <Text>Grandchild Item #1</Text>
            <Children>
              <ChildTopic>
                <Text>Great Grandchild Item #1</Text>
              </ChildTopic>
              <ChildTopic>
                <Text>Great Grandchild Item #2</Text>
                <Children>
                    ... can go an unknown number of levels deep ...
                </Children>
              </ChildTopic>
            </Children>
          </ChildTopic>
        </Children>
      </ChildTopic>
    </Children>
  </Topic>
  <Topic>
    <Text>Item #2</Text>
  </Topic>
  <Topic>
    <Text>Item #3</Text>
  </Topic>
  ... to an unknown number of root TreeItems
</root>
 

TorontoJim

Member
Licensed User
Longtime User
I'm learning a lot with B4J, learning to export and import XML is something I wanted to learn. I already have it importing and exporting the JSON though. The XML is really necessary, it was just academic.
 
Upvote 0
Top