English 中文(简体)
VB6MSXML2 DOMDocument 十三. 财产附录
原标题:VB6 MSXML2 DOMDocument .xml Property appends NewLine character
  • 时间:2011-11-23 14:53:18
  •  标签:
  • xml
  • vb6
  • msxml

我有遗产五B 6号申请,用于维护这些物品。

它使用载荷XML MSXML2.DOMDocument用于从Xml strings中产生,然后使用xml 锡姆尔矿区:

Dim doc As MSXML2.DOMDocument
Set doc = CreateObject("MSXML2.DOMDocument.4.0")
Call doc.loadXML("<doc/>")

  ... manipulation of doc ...

Dim xml As String
xml = doc.xml

我发现了一个与xml财产有关的问题。 在使用上述法典时,护卫Xml在最后拥有新列车:

“entergraph

How can I stop this from happening?

如果能够阻止这种做法(即如果它在MSXML中 s,或者通过设计),那么我如何能够在VB 6中去除。 <>trim(xml)n t work>

EDIT I have updated the question as it it the .xml Property not the .loadXML Method which appears to be at fault. If I select the doc as an Element:

Dim elm As MSXML2.IXMLDOMElement
Set elm = doc.selectSingleNode("doc")
xml = elm.xml

之后是.xml 财产按预期具有无附加特性,因此看来属于DOMDocument.xml财产。

EDIT 2: Following SpectralGhost s answer, here is what I ended up using:

If Right(xml, Len(vbNewLine)) = vbNewLine Then
    xml = Left(xml, Len(xml) - Len(vbNewLine))
End If

我使用“新Line”来避免平台上的具体问题。

最佳回答

这同它一样。

IF RIGHT(xml,2)=vbCrLf THEN
   xml=LEFT(xml,LEN(xml)-2)
END IF
问题回答

XML itself ignores/collapses whitespace so it isn t a problem for the parser. If you really want to get rid of the trailing CRLF, you could try setting doc.preserveWhiteSpace = true.





相关问题
Prevent windows from queuing shellexecute requests

Win.ShellExecute 0, "open", "C:dirprogram.exe", "arguments", vbNullString, SW_SHOWNORMAL Win.ShellExecute 0, "open", "http://www.google.com", vbNullString, vbNullString, SW_SHOWNORMAL I want google....

Why is My Loop Only Deleting One File?

Using VB6 In a folder, i have n number of files, i want to delete a 0 kb files code Dim filename5 As String filename5 = Dir$(txtsourcedatabasefile & "*_*", vbDirectory) MsgBox filename5 Do ...

How to check the filesize?

Using VB6 I have the text file with different sizes, so i want to delete the file where filesize = 0 kb. How to make a vb6 code for deleting the 0 kb files. Need vb6 code Help

File Rename problem?

I m using VB6 and I have a folder where I have n number of files. I want to change the file extension to .txt. I used the code below to change the extension of all .fin files to .txt. Dim filename1 ...

Error 20728-F while in using Crystal Reports in VB6

I m using Crystal Reports in my VB6 project, but I m facing error while loading the report in crystalreport1.action=1; Please give me some solution for this problem. It is showing the error as Error ...

DllRegisterServer entry point was not found

When running my vb6 application I am getting error like, runtime error 53 : file not found: rscomclNoMsg.dll then i tried to register that dll from cmd line using regsvr32. Then I am getting ...

SQL Server 2000, ADO 2.8, VB6

How to determine if a Transaction is active i.e. before issuing Begin Transaction I want to ensure that no previous transaction are open.. the platform is VB6, MS-SQL Server 2000 and ADO 2.8

热门标签