Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to get value for label form XML tag.

Guest
Jun 09, 2016 Jun 09, 2016

To get label for page item I am using below chunk of code. But same code is not working for inline xml tag.

PMString TestUtility::GetScriptLabel(UIDRef pageItemRef, PMString key)

{

    PMString labelValue;

    labelValue.SetTranslatable(false);

    InterfacePtr<IScript> iscript(pageItemRef , IScript::kDefaultIID );

    if(iscript)

    {

        if(key == "default")

        {

            labelValue = iscript->GetTag();

        }

        else

        {

            labelValue = iscript->GetTag(key);

        }

    }

    return labelValue;

}

Please suggest something.

TOPICS
SDK
508
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Engaged , Jun 09, 2016 Jun 09, 2016

The following function should do the job:

PMString GetXMLTagLabel(IDocument* doc, WideString& tagName) {

    PMString label("");

    if(!doc)

      return label;

    InterfacePtr<IXMLTagList> tagList(doc->GetDocWorkSpace(), UseDefaultIID());

    if(tagList)

    {

        UID tagUID  = tagList->GetTag(tagName);

        UIDRef tagRef = UIDRef(::GetDataBase(doc), tagUID);

     

        InterfacePtr<IScript> script(tagRef, UseDefaultIID());

        if(script) {

             label.Append(script->GetTag());

     

...
Translate
Engaged ,
Jun 09, 2016 Jun 09, 2016

Each XML tag (IXMLTag) is an instance of kXMLTagBoss.

If you pass UIDRef of the XML tag then you should be able to get the label using IScript::GetTag.

Ensure that you are passing correct UIDRef.

The following is how you can get UIDRef of an XML Tag using the tag name.

InterfacePtr<IXMLTagList> tagList(document, UseDefaultIID());

UID tagUID  = tagList->GetTag(tagName);

UIDRef tagRef = UIDRef(document.GetDataBase(),tagUID);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jun 09, 2016 Jun 09, 2016

The following function should do the job:

PMString GetXMLTagLabel(IDocument* doc, WideString& tagName) {

    PMString label("");

    if(!doc)

      return label;

    InterfacePtr<IXMLTagList> tagList(doc->GetDocWorkSpace(), UseDefaultIID());

    if(tagList)

    {

        UID tagUID  = tagList->GetTag(tagName);

        UIDRef tagRef = UIDRef(::GetDataBase(doc), tagUID);

     

        InterfacePtr<IScript> script(tagRef, UseDefaultIID());

        if(script) {

             label.Append(script->GetTag());

        }

   }

   return label;

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 10, 2016 Jun 10, 2016
LATEST

Thanks Vinothr your solution worked . I was using ::GetUIDRef() to get uid reference of xml tag but it wasn't working. Thanks for the reference code now i am able to get label for my tag .

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines