Slashdot is powered by your submissions, so send in your scoop

 



Forgot your password?
typodupeerror
×
Programming

Journal Omnifarious's Journal: XML may not be answer, but I'm writing a parser anyway 1

Well, my XML parser understands XML well enough now to turn this:

<fred> <went> <down> <to> <the> <street> </street> <br/> </the> <a><store></store></a></to> </down> </went> </fred>

into this:

<fred>
  <went>
      <down>
        <to>
            <the>
              <street>
              </street>
              <br/>
            </the>
            <a>
              <store>
              </store>
            </a>
        </to>
      </down>
  </went>
</fred>

Yeah, maybe it doesn't seem like much, but in order for the code to do that, it has to understand what a start tag looks like, what an end tag looks like, and what an empty tag looks like. It also has to keep track of the nesting level.

I'm happy about all this because the parser is carefully designed to for two requirements. The first requirement being that it be as fast as possible. The second being that it give me pointers into the original text where the various elements and tags are. The second requirement allows me to cut out or replace pieces of XML documents without altering the parts I'm not changing.

Since the XML messages I'm working with may have pieces that are digitally signed, it is vitally important I leave them exactly as I found them. Any alteration, no matter how slight, would render the signature invalid, and the message would be rejected by the destination. Most XML parsers forget the original document as they construct an internal structure describing the various elements and their relationships that throws away superficial features (like spacing) found in the original document.

Anyway, I'm pleased with my progress. I've had to stop for careful thought along the way to make sure that it was as flexible and fast as possible. I think it'll be fairly widely useful when I'm done.

This discussion has been archived. No new comments can be posted.

XML may not be answer, but I'm writing a parser anyway

Comments Filter:

2.4 statute miles of surgical tubing at Yale U. = 1 I.V.League

Working...