Results 1 to 2 of 2

Thread: XML format change

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2012
    Posts
    37

    XML format change

    I have an XML file that I am making good progress in adding, creating and changing data / nodes / elements.

    There are about 130 children under a parent where there is a node named "//WorkspaceSettings"
    I am unable to get values from any of its children. I created a nodelist that satisfies the requirements but it is not included in the node list.
    If I create a node list using "//WorkspaceSettings/child::*" , I get 2 items. But Nodelist.item(0).nodeName errors, however, nodelist.item(0).Nodtype returns "1" This is the type I get for other nodes where I do get nodename, etc......

    I know that the nodes are there because using a file compare program (Beyond Compare) seems to understand the format and shows these nodes. But using "XML Viewer" shows this data a gobly goop.

    This is a cut of the beginning of the node:

    Code:
    WorkspaceSettings ObjectID="254" ClassID="c4372273-e1aa-4683-98aa-a2ceadf3066c" Version="1">
    	<WorkspaceName>09-26-13C</WorkspaceName>
    	<WorkspaceDefinition>&lt;?xml version='1.0'?&gt;  &lt;prop.map version='4'&gt;  &lt;prop.list&gt;  &lt;prop.pair&gt;  &lt;key&gt;DVA_Wrkspce&lt;/key&gt;  &lt;string&gt;1.2&lt;/string&gt;  &lt;/prop.pair&gt;  &lt;prop.pair&gt;  &lt;key&gt;MonitorInfo&lt;/key&gt;  &lt;prop.list&gt;  &lt;prop.pair&gt;  &lt;key&gt;Monitor-0&lt;/key&gt;  &lt;array&gt;  &lt;array.type&gt;&lt;int type='signed' size='32'/&gt;&lt;/array.type&gt;  &lt;int type='signed' size='32'&gt;0&lt;/int&gt;  &lt;int type='signed' size='32'&gt;22&lt;/int&gt;  &lt;int type='signed' size='32'&gt;2560&lt;/int&gt;  &lt;int type='signed' size='32'&gt;1418&lt;/int&gt;  &lt;/array&gt;  &lt;/prop.pair&gt;  &lt;prop.pair&gt;  &lt;key&gt;Monitor-1&lt;/key&gt;  &lt;array&gt;  &lt;array.type&gt;&lt;int type='signed' size='32'/&gt;&lt;/array.type&gt;  &lt;int type='signed' size='32'&gt;-1276&lt;/int&gt;  &lt;int type='signed' size='32'&gt;416&lt;/int&gt;  &lt;int type='signed' size='32'&gt;1276&lt;/int&gt;  &lt;int type='signed' size='32'&gt;1024&lt;/int&gt;
    Thanks millions for your solution

  2. #2
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    813

    Re: XML format change

    The XPath "child:: *" will return all types of XmlNode, including things like XmlText, which represents the whitespace between elements. That space, including line breaks, is just syntactic sugar for you and I; Xml certainly doesn't need it!

    XmlText is a different Type of node and you can't do half as much with it as you can with a "regular" XmlNode.

    I'd suggest using "child:: node()" instead, which only returns XmlNodes.

    Regards, Phill W.

Tags for this Thread

Posting Permissions

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



Click Here to Expand Forum to Full Width