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

insertHTML won't work with XML files

New Here ,
Mar 15, 2007 Mar 15, 2007

Copy link to clipboard

Copied

I am trying to create a command that writes text to an open XML file. The command I've created works fine under some circumstances but not others.

It works if I open an XML file and apply the command without editing the file. If I make any edits to the file manually and then apply the command, it doesn't insert anything.

It works fine with HTML files in design view, but in code view, if I make any edits and then run the command, nothing happens. If I switch to design view and back again, the command then works fine.

I tested the built-in Dreamweaver command "Flash Text" on an XML file (after editing it so it could be used with an XML file), and the same problem occurs with this command when using it on an XML file. The problem didn't occur with HTML in code view, though.

Below is the .JS file for my command. The corresponding HTML file contains only an empty form.

function canAcceptCommand() {
return(true);
}

function isDOMRequired() {
return false;
}

function commandButtons()
{
return new Array( MM.BTN_OK, "cmdOK(); "
, MM.BTN_Cancel, "cmdCancel();");
}

function cmdOK()
{
var theDOM = dw.getDocumentDOM('document');
theDOM.insertHTML("test", true);
window.close();

}

function cmdCancel()
{
window.close();
}
TOPICS
Extensions

Views

697
Translate

Report

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
Contributor ,
Mar 15, 2007 Mar 15, 2007

Copy link to clipboard

Copied

Everything looks good. I don't see anything that pops out at me that could be causing your problem. I have never tried inserting HTML into an XML file, so I don't kow if that is allowed or not.

Votes

Translate

Report

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
New Here ,
Mar 15, 2007 Mar 15, 2007

Copy link to clipboard

Copied

Would there be any other function besides insertHTML that could possibly be used to insert text into an XML file? insertText won't work, because it converts the characters.

I'm using Dreamweaver MX 2004, by the way.

Votes

Translate

Report

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
Contributor ,
Mar 15, 2007 Mar 15, 2007

Copy link to clipboard

Copied

DWfile.write(), or dreamweaver.createXMLDocument() are the ones I use to maniulate XML files. But I never tried to apply a command to an XML document, normally I just write to one, or create it.

Votes

Translate

Report

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
New Here ,
Mar 15, 2007 Mar 15, 2007

Copy link to clipboard

Copied

I need a function, though, that will insert text at the cursor location in an open file.

I'm also discovering that the command I created above functions erratically even when it does deign to insert the text in an XML file. The text is usually inserted somewher other than where the cursor is located.

Votes

Translate

Report

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
Contributor ,
Mar 15, 2007 Mar 15, 2007

Copy link to clipboard

Copied

Take a look at the "Mark of the Web.js" located in the commands folder. This is very similar to what it sounds like you are doing.

Votes

Translate

Report

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
New Here ,
Mar 15, 2007 Mar 15, 2007

Copy link to clipboard

Copied

I don't seem to have that file in my setup. Is that a feature that was added in Dreamweaver 8?

Votes

Translate

Report

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
Contributor ,
Mar 15, 2007 Mar 15, 2007

Copy link to clipboard

Copied

Yes it is a defualt command. Be sure you access it through Program Files --> Macromedia --> Dreamweaver 8 --> Configuration --> Commands.

Votes

Translate

Report

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
New Here ,
Mar 15, 2007 Mar 15, 2007

Copy link to clipboard

Copied

LATEST
I have DW 8 at home, so I'll check this out tonight or tomorrow. Maybe it's a bug in DW MX. Thanks for all your suggestions.

Votes

Translate

Report

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