Skip to main content
Known Participant
July 28, 2023
Answered

Adobe Indesign with aid tags

  • July 28, 2023
  • 1 reply
  • 824 views

I have to read an indesign.xmlelement.But in the input XML I am having aid:pstyle and aid:cstyle tags.When i am using EvaluateXPathExpression it does not return any value.

In the XML

<table-group></table-group> when i am using rootElement.EvaluateXPathExpression("//table-group") it gives the correct output.

But when I am using <p aid:pstyle="Tx1"></p> It does not return anything. Can you please kindly suggest me to handle aid: attributes containing tags?

 

This topic has been closed for replies.
Correct answer Loic.Aigon

Can you try with Javascript to see where the issue resides? If the javascript works fine, then it means the problem is using the XPath with VB.net. Maybe some xpath expressions are not usable in VB.net or you have to tweak something to make it VB.net compliant.

Also what you can try is start using simpler xpath and add complexity little by little. There you can see where expression interpretation fails.

Cannot help more.

1 reply

Participating Frequently
July 28, 2023

pstyle attribute is namespaced (aid), so you have to include that in your xpath.

A possible way is:

var doc = app.activeDocument;
var root = doc.xmlElements[0];
var elem = root.evaluateXPathExpression('//p[@*[local-name()="pstyle" and namespace-uri()="http://ns.adobe.com/AdobeInDesign/4.0/" and .="Tx1"]]');
if(elem.length==0){
    alert("No elements found");
 }
 else{
    elem = elem[0];
    var xc = elem.xmlContent;
    if(xc.constructor.name=="Text"){
        alert(elem.contents)
    }
    else{
        alert(elem);
    }
    
 } 

May be simpler approaches but that one seems to work.

Loic

PS: You did not mark your question as scripting related, you would have certainly got quicker feedback if you did.

Known Participant
July 29, 2023

Hi thanks for ur reply. But when i am trying this i get Expression expected Error. I am using vb.net 2019 . Thanks once again

Loic.Aigon
Loic.AigonCorrect answer
Legend
August 1, 2023

Can you try with Javascript to see where the issue resides? If the javascript works fine, then it means the problem is using the XPath with VB.net. Maybe some xpath expressions are not usable in VB.net or you have to tweak something to make it VB.net compliant.

Also what you can try is start using simpler xpath and add complexity little by little. There you can see where expression interpretation fails.

Cannot help more.