Skip to main content
edited body
Source Link
TMN
  • 11.4k
  • 1
  • 24
  • 32

Parsing in general is simply driving a state machine, and XML parsing is no different. Stream-based parsing is always a hassle, I always wind up building a stack of some sort to keep track of ancestor nodes, and defining a lot of events and some kind of event dispatcher that checks a tag or path registry and fires off an event if one matches. The core code is fairly tight, but I wind up with a huge wad of event handlers that mostly consist of assigning the value of the following text node to a field in a structure somewhere. It can get pretty hairy if you need to mix business logic in there too.

I would always use DOM unless size ofor performance issues dictated otherwise.

Parsing in general is simply driving a state machine, and XML parsing is no different. Stream-based parsing is always a hassle, I always wind up building a stack of some sort to keep track of ancestor nodes, and defining a lot of events and some kind of event dispatcher that checks a tag or path registry and fires off an event if one matches. The core code is fairly tight, but I wind up with a huge wad of event handlers that mostly consist of assigning the value of the following text node to a field in a structure somewhere. It can get pretty hairy if you need to mix business logic in there too.

I would always use DOM unless size of performance issues dictated otherwise.

Parsing in general is simply driving a state machine, and XML parsing is no different. Stream-based parsing is always a hassle, I always wind up building a stack of some sort to keep track of ancestor nodes, and defining a lot of events and some kind of event dispatcher that checks a tag or path registry and fires off an event if one matches. The core code is fairly tight, but I wind up with a huge wad of event handlers that mostly consist of assigning the value of the following text node to a field in a structure somewhere. It can get pretty hairy if you need to mix business logic in there too.

I would always use DOM unless size or performance issues dictated otherwise.

Source Link
TMN
  • 11.4k
  • 1
  • 24
  • 32

Parsing in general is simply driving a state machine, and XML parsing is no different. Stream-based parsing is always a hassle, I always wind up building a stack of some sort to keep track of ancestor nodes, and defining a lot of events and some kind of event dispatcher that checks a tag or path registry and fires off an event if one matches. The core code is fairly tight, but I wind up with a huge wad of event handlers that mostly consist of assigning the value of the following text node to a field in a structure somewhere. It can get pretty hairy if you need to mix business logic in there too.

I would always use DOM unless size of performance issues dictated otherwise.