[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: How to specify a Processing Instruction? (better: howtocontrolencoding on saving)
- From: Chris Bayes <chris@bayes.co.uk>
- To: 'ComCity' <mikeb@comcity.com>, xml-dev@lists.xml.org
- Date: Thu, 30 Aug 2001 04:00:28 +0100
Mike,
It seems to be happening because you are getting the xml from a
FrontPageEditor.FPHTMLDocument object. FP normalises all space although
I'm not positive that FP would do that here ;-). Goto Tools/Page
Options/HTML Source and make sure the Reformat HTML using the rules
below is unchecked.
Here is a little javascript to show you what you need to do and that it
isn't an xml problem
var xmlSource = new ActiveXObject("MSXML2.DOMDocument.4.0");
var xmlNew = new ActiveXObject("MSXML2.DOMDocument.4.0");
xmlSource.async = false;
xmlSource.load("toolbar.xml");
xmlNew.loadXML("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><foo/>");
var lictext =
xmlSource.selectSingleNode("/AccessLicenseRequest/AccessLicenseProfile/A
ccessLicenseText");
xmlNew.selectSingleNode("/foo").appendChild(lictext);
xmlNew.save("new.xml");
C:>cscript above.js
New.xml is saved with the required white space and encoding.
Ciao Chris
P.s. your original UPS document is invalid. It is declared as
<?xml version="1.0"?> and yet contains "UPS ONLINER TOOLS ACCESS USER
TERMS".
R is invalid in a utf-8 document.
XML/XSL Portal
http://www.bayes.co.uk/xml
> -----Original Message-----
> From: ComCity [mailto:mikeb@comcity.com]
> Sent: 30 August 2001 01:52
> To: s.livingstone@btinternet.com; xml-dev@lists.xml.org
> Subject: Re: How to specify a Processing Instruction?
> (better: how tocontrolencoding on saving)
>
>
> P.S. This is my code, maybe you see something I did wrong.
> I know I used LoadXML...instead of Load as you described, but
> I get an error when I use Load. The Msgbox in the If
> statement catches the error as "Could not Open XML Access
> License Request." and then the line AccessLicXml.replaceChild pi,
> AccessLicXml.childNodes.Item(0) further fails because
> AccessLicXml is empty.
>
> Dim AccessLicXml As MSXML2.DOMDocument
> Dim XmlRoot As IXMLDOMElement
> Dim XmlString
> Dim MyPageDoc As PageWindow
> Dim MyDocObject As FPHTMLDocument
> Dim ShippingLoc As String
> Dim ReqXmlStr As String
> GetPath FpApp.ActiveWeb.RootFolder, ShippingLoc, False
> ShippingLoc = ShippingLoc & "/ups/accesslicensereq.xml"
> 'ShippingLoc = ShippingLoc & "/ups/ups.xml"
> FpApp.ActiveWeb.LocateFile(ShippingLoc).Edit
> Set MyDocObject = FpApp.ActivePageWindow.ActiveDocument
> Set AccessLicXml = New MSXML2.DOMDocument
> ReqXmlStr = MyDocObject.DocumentHTML
> Set MyPageDoc = FpApp.ActivePageWindow
> MyPageDoc.Close
> If Not AccessLicXml.loadXML(ReqXmlStr) Then
> MsgBox "Could not Open XML Access License Request",
> vbOKOnly + vbCritical, "SalesCart Error"
> End If
>
> 'Dim pi As IXMLDOMProcessingInstruction
> Set pi = AccessLicXml.createProcessingInstruction("xml",
> "version='1.0'
> encoding='ISO-8859-1'")
> AccessLicXml.replaceChild pi, AccessLicXml.childNodes.Item(0)
> MsgBox (AccessLicXml.xml)
>
> Anyway, I'm either totally lost or none of this stuff is
> working the way everyone says.
>