Jump to content

how to edit only opening tag or closing tag of an xml file


ElGato

Recommended Posts

How to edit only opening tag or closing tag of an xml file?

Or how to create a valid one.. since java is creating automatic closing tags with the same name and i have

<img id="2" src="item1.jpg">

 

what i get is <img id="2" src="item1.jpg"> bla bla </img id="2" src="item1.jpg"> and the browser expect for a ">" after "<img"

 

doc.createElement("img id=\"2\" src=\"item1.jpg\"" );

 

Any suggestions will be apreciated

 

 

Link to comment
Share on other sites

What you need to do is create the element first, then add attributes.

img = doc.createElement("img");
img.setAttribute("id". "2");
img.setAttribute("src", "item1.jpg");

I'm not sure if this is Java or Javascript you're talking about.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...