html as xml document on IE

Discussion in 'Javascript' started by RoLo, Apr 18, 2008.

  1. RoLo

    RoLo Guest

    Is there anyway to use the html document on IE as an XML document?
    RoLo, Apr 18, 2008
    #1
    1. Advertising

  2. "RoLo" wrote:
    > Is there anyway to use the html document on IE as
    > an XML document?


    Only a subset of HTML documents could pass XML's well-formed-ness rules
    (they could not include any elements with EMPTY content declarations, so
    no img, input, link or mata elements for a start, HTML's optional tags
    could not be omitted (except where both opening and closing tags can be
    omitted) and all attribute values would have to be quoted regardless of
    whether quoting them would have been unnecessary in HTML). I don't see
    what being "on IE" would have to do with anything, except that once a
    document is being rendered by IE using its - inner/outerHTML -
    properties as a source for the text that would be treated as XML would
    be a non-starter as there attributes that do not need to be quoted are
    almost never quoted.

    Richard.
    Richard Cornford, Apr 18, 2008
    #2
    1. Advertising

  3. RoLo

    RoLo Guest

    On Apr 18, 1:22 am, "Richard Cornford" <>
    wrote:
    > "RoLo" wrote:
    > > Is there anyway to use the html document on IE as
    > > an XML document?

    >
    > Only a subset of HTML documents could pass XML's well-formed-ness rules
    > (they could not include any elements with EMPTY content declarations, so
    > no img, input, link or mata elements for a start, HTML's optional tags
    > could not be omitted (except where both opening and closing tags can be
    > omitted) and all attribute values would have to be quoted regardless of
    > whether quoting them would have been unnecessary in HTML). I don't see
    > what being "on IE" would have to do with anything, except that once a
    > document is being rendered by IE using its - inner/outerHTML -
    > properties as a source for the text that would be treated as XML would
    > be a non-starter as there attributes that do not need to be quoted are
    > almost never quoted.
    >
    > Richard.


    ok, I understand your point, I should have been more specific...

    After the HTML is loaded... Is there anyway I could use the document
    as an XML document. In firefox, opera and safari the html document
    inherits
    their XML document methods. In IE it doesn't, at least I haven't found
    any
    direct way to this, so thats why Im asking.
    RoLo, Apr 18, 2008
    #3
  4. RoLo wrote:
    > After the HTML is loaded... Is there anyway I could use the document
    > as an XML document. In firefox, opera and safari the html document
    > inherits their XML document methods.


    No, it does not. It would seem that you either mistake the methods of DOM
    Level 2+ Core as being XML-DOM-specific, or you have not understood the
    difference between HTML and XHTML.

    > In IE it doesn't, at least I haven't found any direct way to this,
    > so thats why Im asking.


    IE does not implement W3C DOM Level 2 for the most part.

    You should ask *exactly* what you would like to know instead, and be
    prepared to answer the "Why?" question.


    PointedEars
    --
    Anyone who slaps a 'this page is best viewed with Browser X' label on
    a Web page appears to be yearning for the bad old days, before the Web,
    when you had very little chance of reading a document written on another
    computer, another word processor, or another network. -- Tim Berners-Lee
    Thomas 'PointedEars' Lahn, Apr 18, 2008
    #4
  5. RoLo

    The Magpie Guest

    RoLo wrote:
    >
    > ok, I understand your point, I should have been more specific...
    >

    Actually, I think you miss the point if you don't mind me saying. The
    point is that HTML is just not a valid XML format file. I think you
    have misunderstood the difference between HTML (not valid XML) and
    XHTML (which is more or less valid XML). Loaded or not does not make a
    difference to its validity.
    The Magpie, Apr 18, 2008
    #5
  6. RoLo

    RoLo Guest

    On Apr 18, 5:34 pm, The Magpie <> wrote:
    > RoLo wrote:
    >
    > > ok, I understand your point, I should have been more specific...

    >
    > Actually, I think you miss the point if you don't mind me saying. The
    > point is that HTML is just not a valid XML format file. I think you
    > have misunderstood the difference between HTML (not valid XML) and
    > XHTML (which is more or less valid XML). Loaded or not does not make a
    > difference to its validity.


    whats so hard to understand about my question?
    "Is there anyway to use the html document on IE as an XML document?"

    "After the HTML is loaded... Is there anyway I could use the document
    as an XML document."

    can't you read "Is there ANYWAY" in both replies?

    "Loaded or not does not make a difference to its validity."
    I pointed out after load, because I can't use the DOM if the HTML
    source
    is not loaded in the browser. After all, this is a Javascript mailing
    list not an XML one!


    I know that copying the html document elements to a new xml document
    is possible
    but I was hoping there was a better way to do it for IE. After all
    FF,Opera and Safari
    kind of merges XML and HTML in their document DOM.

    http://developer.mozilla.org/en/docs/DOM:document

    In conclusion, the only way possible (at least the simplest way) on IE
    is by copying
    the HTML document into an XML document.
    RoLo, Apr 19, 2008
    #6
  7. RoLo

    Evertjan. Guest

    RoLo wrote on 19 apr 2008 in comp.lang.javascript:

    > whats so hard to understand about my question?
    > "Is there anyway to use the html document on IE as an XML document?"
    >
    > "After the HTML is loaded... Is there anyway I could use the document
    > as an XML document."
    >
    > can't you read "Is there ANYWAY" in both replies?


    That doesn't mean a thing.
    Did you perhaps mean "any way"?

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan., Apr 19, 2008
    #7
  8. RoLo

    RoLo Guest

    On Apr 19, 1:52 pm, "Evertjan." <> wrote:
    > RoLo wrote on 19 apr 2008 in comp.lang.javascript:
    >
    > > whats so hard to understand about my question?
    > > "Is there anyway to use the html document on IE as an XML document?"

    >
    > > "After the HTML is loaded... Is there anyway I could use the document
    > > as an XML document."

    >
    > > can't you read "Is there ANYWAY" in both replies?

    >
    > That doesn't mean a thing.
    > Did you perhaps mean "any way"?
    >
    > --
    > Evertjan.
    > The Netherlands.
    > (Please change the x'es to dots in my emailaddress)


    http://dictionary.reference.com/browse/anyway

    Yes I meant "any way", since my native language is not english
    Im not sure if I used "anyway" correctly, but im sure
    anyway means "any way". Even so, I been not native
    english speaker, could have deduce the correct "any way"
    meaning. Im more of a programmer type of guy then a
    orthography freak.. even more if im not a native to the language...
    RoLo, Apr 19, 2008
    #8
  9. RoLo wrote:
    > On Apr 18, 5:34 pm, The Magpie <> wrote:
    >> RoLo wrote:
    >>> ok, I understand your point, I should have been more specific...

    >> Actually, I think you miss the point if you don't mind me saying. The
    >> point is that HTML is just not a valid XML format file. I think you
    >> have misunderstood the difference between HTML (not valid XML) and
    >> XHTML (which is more or less valid XML). Loaded or not does not make a
    >> difference to its validity.

    >
    > whats so hard to understand about my question?
    > "Is there anyway to use the html document on IE as an XML document?"


    That of itself it does not make any sense?

    > "After the HTML is loaded... Is there anyway I could use the document
    > as an XML document."
    >
    > can't you read "Is there ANYWAY" in both replies?


    That does not matter at all. You cannot use an HTML document as an XML
    document, period.

    > "Loaded or not does not make a difference to its validity."
    > I pointed out after load, because I can't use the DOM if the HTML
    > source is not loaded in the browser. After all, this is a Javascript
    > mailing list not an XML one!


    To begin with, this is not even a mailing list. It is a Usenet newsgroup.

    > I know that copying the html document elements to a new xml document
    > is possible


    It is not. There appears to be at least one major misconception on your part.

    That said, it would help to clarify this if you posted *some* code that you
    *think* it does what you think, at least. As the URL you have provided is
    not helpful for understanding what you may mean.


    PointedEars
    --
    Anyone who slaps a 'this page is best viewed with Browser X' label on
    a Web page appears to be yearning for the bad old days, before the Web,
    when you had very little chance of reading a document written on another
    computer, another word processor, or another network. -- Tim Berners-Lee
    Thomas 'PointedEars' Lahn, Apr 19, 2008
    #9
  10. RoLo

    VK Guest

    On Apr 19, 9:21 pm, RoLo <> wrote:
    > whats so hard to understand about my question?
    > "Is there anyway to use the html document on IE as an XML document?"
    >
    > "After the HTML is loaded... Is there anyway I could use the document
    > as an XML document."


    I don't care of "way, anyway" and I am not native English speaker
    neither. But what do you mean by "use HTML as XML"?
    1) Do you need some specific DOM Element property/methods provided by
    default on some browser(s) but missing in IE DOM model?
    2) Are you augmenting all DOM elements with your custom property/
    methods and asking how to do it in IE?
    3) Do you need to retrieve HTML document DOM tree and to create a well-
    formed XML fragment out of it?
    4) ?
    5) ?

    Really, the tasks are so different that we need a clarification. You
    should not expect people giving 2-3-many solutions at once in hope
    that at least one will be corresponding to what are you asking about.
    VK, Apr 19, 2008
    #10
  11. RoLo

    Evertjan. Guest

    RoLo wrote on 19 apr 2008 in comp.lang.javascript:

    > On Apr 19, 1:52 pm, "Evertjan." <> wrote:
    >> RoLo wrote on 19 apr 2008 in comp.lang.javascript:
    >>
    >> > whats so hard to understand about my question?
    >> > "Is there anyway to use the html document on IE as an XML document?"

    >>
    >> > "After the HTML is loaded... Is there anyway I could use the document
    >> > as an XML document."

    >>
    >> > can't you read "Is there ANYWAY" in both replies?

    >>
    >> That doesn't mean a thing.
    >> Did you perhaps mean "any way"?


    [please do not quote signatures on usenet]]

    > Yes I meant "any way", since my native language is not english
    > Im not sure if I used "anyway" correctly, but im sure
    > anyway means "any way".


    It does not. Hoewver you were stressing that others were not following you.

    > Even so, I been not native
    > english speaker, could have deduce the correct "any way"
    > meaning. Im more of a programmer type of guy then a
    > orthography freak.. even more if im not a native to the language...


    Programming begins at correct syntax. The syntax of HTML and XML for
    instance, are incompatible, the two words just do not mean the same thing,
    like "anyway" and "any way" in your sentence(!!), the last meaning "any
    method" the first meaning more something like [but not exactly] "in spite
    of".

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan., Apr 19, 2008
    #11
  12. RoLo

    RoLo Guest

    ok, sorry I suck at social skills...
    seems im the one with problems communicating,
    let me try again,

    When Im saying HTML document im thinking in something
    like:
    A=window.document <-- HTML document

    the XML document would be:
    B=new ActiveXObject("Msxml2.DOMDocument") <-- an XML document in IE

    my question was,
    Is there any way I could use A with methods from B in IE?

    Why I ask this?
    In Firefox, Safari and Opera for example I can use elements from A
    with,
    for example: alert((new
    XMLSerializer()).serializeToString(window.document.body));

    Not that this is what I wanted to do, this is just an example of what
    im talking
    about, in IE I can't use A elements with XML functions,
    methods...etc..

    So... I was asking, just in case there was some sort of way to do this
    (use A elements with XML DOM).

    Im not saying that A==B.

    @PointedEars,
    when I said copy the elements I meant:
    // src childNodes
    // dest destination document
    var copyNodes=function(src,dest)
    {
    var l=function(a,c)
    {
    for(var i=0;i<c.length;i++)
    {
    if(c.nodeType==1)
    a.appendChild(k(c));
    else if(c.nodeType==3)
    a.appendChild(dest.createTextNode(c));
    }
    },
    k=function(a)
    {
    var e=dest.createElement(a.nodeName),attr,i;

    // copy attributes
    attr=a.attributes;
    for(i=0;i<attr.length;i++)
    e.setAttribute(attr.name,attr.value);

    // copy childs
    l(e,a.childNodes);
    return e;
    };

    l(dest,src);
    };


    @Evertjan, at least im not the only one:
    http://www.google.com/search?q="is there anyway"
    RoLo, Apr 19, 2008
    #12
  13. RoLo

    The Magpie Guest

    RoLo wrote:
    > On Apr 18, 5:34 pm, The Magpie <> wrote:
    >> RoLo wrote:
    >>
    >> [snip] The point is that HTML is... not a valid XML format file.
    >> [snip]

    >
    > whats so hard to understand about my question?
    > "Is there anyway to use the html document on IE as an XML document?"
    >

    There is nothing hard in the question. What is so hard about the
    answer "because it is *NOT* an XML file"?
    The Magpie, Apr 21, 2008
    #13
  14. RoLo

    Hal Rosser Guest

    Hal Rosser, Apr 22, 2008
    #14
  15. RoLo

    RoLo Guest

    On Apr 21, 2:45 pm, The Magpie <> wrote:
    > RoLo wrote:
    > > On Apr 18, 5:34 pm, The Magpie <> wrote:
    > >> RoLo wrote:

    >
    > >> [snip] The point is that HTML is... not a valid XML format file.
    > >> [snip]

    >
    > > whats so hard to understand about my question?
    > > "Is there anyway to use the html document on IE as an XML document?"

    >
    > There is nothing hard in the question. What is so hard about the
    > answer "because it is *NOT* an XML file"?


    ok, why would I ask such a question in a Javascript newgroup?
    I didn't expect an XML != answer I was expecting some tips on
    how I could use HTML as an XML!!! And by use I mean with XML DOM!
    Hal posted a good tip (converting the source).. but I was
    expecting a Javascript tip.

    I do have a Javascript way of doing this (converting the DOM),
    as I have replied before, by "copying" the HTML document into
    a new XML document. (by document I mean the Javascript object
    created by the browsers, not the source)

    I don't know how I can be more specific... sorry if im not
    explaining my self so well.
    RoLo, Apr 23, 2008
    #15
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mike
    Replies:
    2
    Views:
    501
    Chris Smith
    Jan 14, 2005
  2. mike
    Replies:
    3
    Views:
    479
    Thomas Weidenfeller
    Jan 24, 2005
  3. Tony Prichard
    Replies:
    0
    Views:
    717
    Tony Prichard
    Dec 12, 2003
  4. Manish Hatwalne
    Replies:
    1
    Views:
    392
    Martin Honnen
    Jul 13, 2004
  5. icogs
    Replies:
    0
    Views:
    129
    icogs
    Jan 31, 2008
Loading...

Share This Page