Updating xml

Hi,

If I have a schema that has an unbounded element in it, for example a party may have many addresses, and I want to know how many of these are populated when I access the data, how do I know how many occurrences are populated? I assume that I would have to loop through the data to find out how many are populated, how do I do this with Javascript?

This raises the question of how do I then update the 5th occurrence in this unbounded element and save it back to the repository?



We currently using html/Javascript.

Thanks

Miklos Hagymassy

Using the MSXML DOM you don’t need to count the number of elements because the IXMLDOMNodeList interface has a length property, e.g

var Party = …
var Address = Party.childNodes ;
var numAddress = Address.length ;

For updating the whole document if using IIS, MSXML DOM there are two options:
- get the whole document instance, make the modifications to the DOM tree and process the whole document back to Tamino. Tamino will do an update (and not an insert) if the root element contains the ino:id attribute.
- use NodeLevelUpdate feature. There’s an excellent FAQ on this feature that can be found here.

…just to illustrate what Stuart has suggested, here’s a small javascript example that you should be able to modify to suit your needs.

HTH
example.js (2 KB)

Thank you

Miklos Hagymassy