Skip to main content
wolfgangappel
Participant
September 4, 2014
Question

Process XML attributes of all tables in a structured document

  • September 4, 2014
  • 1 reply
  • 306 views

Hi all,

I try to process the XML attributes of all tables in a structured document.

When I use SelectedTbl everything works fine for the selected table and the attributes of the tabelle Element are written correctly to the Console.

doc = app.ActiveDoc;

table = doc.SelectedTbl;

if (table.TblElement)

{

    Console('Elementname: ' + table.TblElement.ElementDef.Name);

    tblEle = table.Element;

    attrs = tblEle.GetAttributes();

    for (i = 0; i < attrs.len; i++) {

        aName = attrs.name;

        aWert = attrs.values;

        Console( "     " + aName + "    " + aWert);     

    }

}

However when I use GetText(Constants.FTI_TblAnchor) to walk through all tables of the documens neither ElementDef.Name nor Attributes are processed.

var flow = doc.FirstFlowInDoc;

var textItems = flow.GetText(Constants.FTI_TblAnchor);

while(iTab<textItems.length) {

table = textItems[iTab].obj;

if (table.TblElement)

{

    Console('Elementname: ' + table.TblElement.ElementDef.Name);

    tblEle = table.Element;

    attrs = tblEle.GetAttributes();

    for (i = 0; i < attrs.len; i++) {

        aName = attrs.name;

        aWert = attrs.values;

        Console( "     " + aName + "    " + aWert);     

    }

}

}

Any Suggestions?

Yours

Wolfgang

This topic has been closed for replies.

1 reply

Inspiring
September 5, 2014

You'll probably want all the tables from the main flow. Try

var flow = doc.MainFlowInDoc;

Kind regards

JoH