XML DOMNode.Text

ta5ta5 Member Posts: 1,164
Hi
I have a strange issue with the xml domnode.text, if the text is very long (> 250?).

Both of the 2 ffw. code snippets produce the error "The length of the text string exceeds the size of the string buffer". NewValue is a string with the maxlength of 250.

1)
NewValue := COPYSTR(DOMNode.text,1,250);

2)
DOMNodeText.data := DOMNode.text; //error happens here
NewValue := DOMNodeText.substringData(1,250);

Any ideas? Thank you in advance
Thomas

PS: I hope I didn't post twice, because there was an error with the internet connection when I wanted to post 1 hour ago...

Comments

  • ta5ta5 Member Posts: 1,164
    Hi
    Still having the same problem, maybe it's how Navision handles automation objects, see
    http://www.mibuso.com/forum/viewtopic.php?t=7980

    Any ideas/comments will be appreciated.

    Many thanks in advance.
    Thomas
  • fbfb Member Posts: 246
    You almost had it in your example 2 --

    The text of a DOMNode is an object of type IXMLDOMText. You can get at it like this:
    DOMText := DOMNode.firstChild;
    NewValue := DOMText.substringData(1,250);
    
  • ta5ta5 Member Posts: 1,164
    Hi
    Thank you for your info. So far it works now.

    CREATE(XMLDom);
    XMLDom.async := FALSE;
    XMLDom.load('c:\books.xml');
    DOMElement := XMLDom.documentElement;
    DOMNode := DOMElement.selectSingleNode('//book/description');

    // this works
    DOMNodeText := DOMNode.firstChild;

    // this produces a compile error "an assigment is not allowed for this //variable
    DOMNodeText := DOMNode.text;

    NewValue := DOMNodeText.substringData(1,250);


    Anyway, I'm not so happy with the firstchild property. Is there no way to use the text property?

    Thanks in advance
    Thomas
  • DenSterDenSter Member Posts: 8,307
    Assuming that your DOMNode variable is a 'Microsoft XML, v3.0'.IXMLDOMNode object, the Text property should be accessible. It works for me in a number of XML codeunits.
  • ta5ta5 Member Posts: 1,164
    Hi Daniel
    DenSter wrote:
    Assuming that your DOMNode variable is a 'Microsoft XML, v3.0'.IXMLDOMNode object, the Text property should be accessible. It works for me in a number of XML codeunits.

    Does this work for you with Text longer than 250 too? If yes, can you post the code snippet?
    To precise my last posting: For me it seems more consequent to use the text-property of a node, rather than use the firstchild-property. However, firstchild works with long text, text doesn't. :?

    Any comments to that?
    Thomas
Sign In or Register to comment.