Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2003
    Posts
    32

    Unanswered: Couldn't output CORRECT character for XML entities.

    Hi,

    I have the following XML file
    -----------------------------
    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE book SYSTEM "book.dtd">
    <book>
    <chapter>
    <chapinfo>
    <title>THE EFFECT OF &mdash; CONSERVATION LAWS</title>
    <author>Tom Sealy</author>
    </chapinfo>
    <chapbody>
    Colonel Drake &mu; discovered oil in Pennsylvania.
    </chapbody>
    </chapter>
    </book>
    -----------------------------

    The DTD is...
    -----------------------------
    <?xml encoding="utf-8"?>

    <!ENTITY % Text "(#PCDATA)*">

    <!ELEMENT book (chapter*)>
    <!ELEMENT chapter (chapinfo,chapbody)>
    <!ELEMENT chapinfo (title,author)>
    <!ELEMENT chapbody %Text;>

    <!ELEMENT title %Text; >
    <!ELEMENT author %Text; >

    <!ENTITY mdash "—">
    <!ENTITY mu "&#x3BC;">
    -----------------------------

    Now I wrote a VB program that accesses this XML file and updates the Access Database.
    Here goes a fragment of it...
    ------------------------------
    Dim objXMLDOM As New MSXML2.DOMDocument
    Dim objNodes As IXMLDOMNodeList
    Dim objBookNode As IXMLDOMNode
    Dim title As IXMLDOMNode
    Dim author As IXMLDOMNode
    Dim body As IXMLDOMNode

    objXMLDOM.Load("book.xml")

    Set objNodes = objXMLDOM.selectNodes("/book")
    For Each objBookNode In objNodes
    'go to all chapters nodes
    For Each child In objBookNode.childNodes
    ch=child.childNodes(0).childNodes(0)
    If ch.nodeName = "title" then
    t=ch.nodeTypedValue
    'insert t in the field "title" of the chapter table
    End If
    ......
    Next
    Next
    ------------------------------
    But the problem is that, the entities are not correctly replaced with their character equivalents. Instead, a square symbol(”) is inserted in its place.

    Can anyone tell me how I could let my program convert these entities into CORRECT character representation?

    Any help is grately appreciated!

    Thanks a lot!

    -Srivalli.

  2. #2
    Join Date
    Oct 2003
    Posts
    32
    In the above post, the entities are correctly replaced(both in the XML file and the DTD) by the characters they represent.

    mdash stands for &_#_151_; (without _ )
    mu stands for &_#_x3BC_; (without _ )

    But my VB program puts them as square symbols, for some unknown reason. Could anyone solve this?

    Thanks.

    -Srivalli.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •