Consulting

Results 1 to 3 of 3

Thread: Setting ".Text" value of XML Attribute Node Changes Node Index Order???

  1. #1
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,334
    Location

    Setting ".Text" value of XML Attribute Node Changes Node Index Order???

    Cross posted at: https://www.msofficeforums.com/word-vba/42960-setting-text-value-xml-attribute-node-changes.html#post143240
    and
    https://social.msdn.microsoft.com/Fo...um=xmlandnetfx

    The attached file should help illustrate the issue.

    I recently put together a process to populate a userform Listbox using data in a document CustomXMLPart using child nodes of a parent ListEntry node:

    1.jpg

    Next, I thought it would be an interesting exercise to see if I could use attributes (vice child nodes) e.g.,:

    2.jpg

    However, I discovered that whenever I attempted to redefine the attribute values using the .Attributes property and index, the order of the attributes was altered in the XML e.g.,:

    m_oCXNode.Attributes(1).Text = txtEditName
    m_oCXNode.Attributes(2).Text = txtEditRank
    m_oCXNode.Attributes(3).Text = txtEditSN

    resulted in the following:

    3.jpg

    I've worked around this issue in the attached but would sure like to understand why that happens or get a suggestion on a better forum to publish this issue.

    Paul, if I've committed some breach of cross posting protocol, please advise and I will attempt to correct.

    Thanks
    Last edited by gmaxey; 07-14-2019 at 09:00 AM.
    Greg

    Visit my website: http://gregmaxey.com

  2. #2
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,334
    Location
    Greg

    Visit my website: http://gregmaxey.com

  3. #3
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,334
    Location
    Have revised the original demonstration document to reflect lesson learned wrt unordered attributes in XML structure.

    If anyone has any comment (constructive or otherwise), please post.
    Greg

    Visit my website: http://gregmaxey.com

Posting Permissions

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