Header and special type in XML document

RallnusRallnus Member Posts: 79
edited 2005-04-20 in Navision Attain
I search for a solution to get the following results:

The xml-Dokument should have a header like this:

<?xml version="1.0" encoding="ISO-8859-1" ?>


Some nodes should have the extension "type.." or "version.."

<PARTY_ID type="buyer_specific">0662406</PARTY_ID>

or

<ORDERRESPONSE version="1.0">

How can i specialize a node like this?

Thx for your input..
Rallnus (Yamaha FJ1200 - '89 / 25th anniversary was great!)

Answers

  • jhoekjhoek Member Posts: 216
    The XML declaration is a special type of processing instruction. Use the XMLDOMDocument's createProcessingInstruction and appendChild methods to add this to your document.

    Attributes, such as "type" in your example, can most easily be set using the setAttribute method of an XMLDOMElement.
    Kind regards,

    Jan Hoek
    Product Developer
    Mprise Products B.V.
  • RallnusRallnus Member Posts: 79
    jhoek, thank you very much!
    But I've got 2 problems left:

    1. I get an error when i try to use the function "insert before", because it isn't allowed to insert a processing instruction before the first node.


    2. when i read xml-files the import will break, when the file contents special signs like @, &... how can i improt files with these signs?

    greetings, rallnus
    Rallnus (Yamaha FJ1200 - '89 / 25th anniversary was great!)
  • jhoekjhoek Member Posts: 216
    Ad 1.
    Perhaps you should append the processing instruction before you do anything else. I used this technique several times and the past, and never experienced any problems. Post a snippet of your code to this forum if your problem persists.

    Ad 2.
    I think you should escape these special characters as follows:

    & must be replaced with &
    < must be replaced with <
    > must be replaced with >
    ' must be replaced with '
    " must be replaced with "

    (the trailing semicolon is part of the entity)
    Kind regards,

    Jan Hoek
    Product Developer
    Mprise Products B.V.
  • jhoekjhoek Member Posts: 216
    Ad 1.
    Perhaps you should append the processing instruction before you do anything else. I used this technique several times and the past, and never experienced any problems. Post a snippet of your code to this forum if your problem persists.

    Ad 2.
    I think you should escape these special characters as follows:

    & must be replaced with &
    < must be replaced with <
    > must be replaced with >
    ' must be replaced with '
    " must be replaced with "

    (the trailing semicolon is part of the entity)
    Kind regards,

    Jan Hoek
    Product Developer
    Mprise Products B.V.
Sign In or Register to comment.