I have a schema that has an element of Author and sub elements of titles by that author. I hav a JScript to Bring back the documents, I can cycle through each Author, but do not know how to get the sub-elements. I was using the getElementsByTagName, but cannot even find that in the documenttion. Any Suggestions, or samples.
The getElementsByTagName() is part of the DOM implementation and the JScript API uses the Microsoft XML SDK 3.0. If you take a look at the Tamino API JScript documentation (…\Help\JScript\APIUSING.HTM#apiusing) there is a section called “Performing a Query” which contains a snippet of code making use of getElementsByTagName().
To get the documentation for the XMLDOM implementation, go the Microsoft website and download the entire SDK including documentation. You can get to it from here.
Hope this helps.
Basically my structure is that I have an Author, and then on the same document, all his titles.
My querey brings back the correct docuement, but I am having trouble cycling through the titles for that document. I am on my way, with the docs, I think I can get it. I already have it working by altering the index in the following
statment
(itemSelected.getElementsByTagName(“Title”).item(1).childNodes.item(0).data);
The item goes through the ones, but my problem now is to figure out how far I can go. If I go beyond the number of titles, I get errors (Document Required) or some such.
The problem is that I am just learning JSCRIPT at the same time.
Assume you are processing documents like:-
<?xml version="1.0"?>
All’s Well That Ends Well
As You Like It
…
and you want to iterate through the titles, you can do something like:
function doexample()
{
tc = new TaminoClient(“http://localhost/tamino/welcome3_1_1_4/ino:etc”);
tr = tc.query (“Author”) ;
tr = tr.DOM ;
titles = tr.documentElement.getElementsByTagName (“Title”) ;
txt = “” ;
len = titles.length ;
// build up some HTML to display titles
for (i = 0 ; i < len ; i++)
{
txt = txt + titles.item(i).childNodes.item(0).text + “
” ;
}
idresults.innerHTML = txt ;
}
That looks like what I needed. I had it all except the two parts to get the length of the Title section. So I am sure this will work.