Skip to main content
Inspiring
July 17, 2018
Answered

[ESTK]Add new XML attribute in new XML(**str**)

  • July 17, 2018
  • 2 replies
  • 1015 views

Hi all,

Here is my code not working.

/////

var xmFile = new File("/Users/user/Desktop/Test.xml");

xmFile.open('r');

var xmCont = xmFile.read();

var myXML = new XML(xmCont);

var tmpXpath = "//imagedata[@fileref]";

var xmlXPath = myXML.xpath(tmpXpath);

if(xmlXPath.length() > 0)

{

    xmlXPath[0].attibutes.add("href", "file:///Users/user/Desktop/Figures/Images/Test.jpg");   //Error at this line

}

Please give any helps!!

thanks,

John.

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

Thank E4X…

xmlXPath[0].@href = "file:///Users/user/Desktop/Figures/Images/Test.jpg";

2 replies

payalm68947498
Inspiring
July 17, 2018

Hey attributes spelling is wrong,

xmlXPath[0].attibutes.add("href", "file:///Users/user/Desktop/Figures/Images/Test.jpg")

Legend
July 17, 2018

Try this,

    xmlXPath[0].xmlAttributes.add("href", "file:///Users/user/Desktop/Figures/Images/Test.jpg");

AD4003Author
Inspiring
July 17, 2018

Hi Sajeev,

Again an error occurred in same line.

Error is: xmlXPath[0].xmlAttributes.add is not a function

Loic.Aigon
Loic.AigonCorrect answer
Legend
July 18, 2018

Thank E4X…

xmlXPath[0].@href = "file:///Users/user/Desktop/Figures/Images/Test.jpg";