Jump to content
mLipok

XML.au3 - BETA - Support Topic

Recommended Posts

1 hour ago, Hiyoal said:

Different length than yours but the object is of the same type??

That means that we are not using the same xml file.  Which leads me to believe that there may be even more differences.  Did you make any changes to any of the files after you unzipped it?

 

*** Update ***

I just downloaded the latest version again and I get a length of 13 also.

Edited by TheXman

Share this post


Link to post
Share on other sites

@Hiyoal

Okay, I think I found the issue.  The difference is my xml.au3.  It appears that I had found an issue with it a while ago and fixed it in my version.  The issue actually was related to Example 6. 

Please try the xml.au3 file that I have attached.  Please let me know if it resolves the issue you are having.  You can do a diff between mine and the one in the latest zip if you want to see the modifications.  There are only 2 changes.  One line was modified and the other line was added.

 

@mLipok

If you need an explanation of my modifications, please let me know.  I would be happy to explain the issue that I found and how the 2 lines fix the issue with Example 6.

 

 

XML.au3

Edited by TheXman

Share this post


Link to post
Share on other sites

Champion. 

Thats working now for the example and my own script.

I saw the changes. The addition to validate the object made sense but I didn't understand the removal of the "#text" ContinueLoop in that for loop.

Im stoked I wasn't going bonkers, thanks for the help TheXman.

Share this post


Link to post
Share on other sites

 

You're welcome!   :thumbsup:

 

2 minutes ago, Hiyoal said:

I didn't understand the removal of the "#text" ContinueLoop in that for loop.

It has to do with the  data in the _ArrayDisplay().  If you comment out that line, you will see #text entries in the table and you will see several COM errors saying something about trying to assign null objects.  So basically that line just omits any #text properties from being added to the table, which also prevents the COM errors.

Share this post


Link to post
Share on other sites

Haha makes sense.

As soon as I wrote my post I started tinkering away with checking nodeNames individually without going through _XML_Array_GetNodesProperties and saw all of those #text entries.

Share this post


Link to post
Share on other sites
Posted (edited)
On 9/28/2019 at 3:49 AM, TheXman said:

 

You're welcome!   :thumbsup:

 

It has to do with the  data in the _ArrayDisplay().  If you comment out that line, you will see #text entries in the table and you will see several COM errors saying something about trying to assign null objects.  So basically that line just omits any #text properties from being added to the table, which also prevents the COM errors.

Hi TheXman,

I'm having a strange issue while using "_XML_CreateDOMDocument","_XML_Load" "_XML_SaveToFile" .

While opening Windows SIM "unattend.xml" files using your "XML.au3" UDF (By the way great work by picking up "eltorro" code and adding extra features)

I'm having some issues:

Using "_XML_CreateDOMDocument" and setting up as "Default" (in my case it ends up being "6") I get the following output (upon Load and SaveToFile😞

 

<?xml version="1.0" encoding="utf-8"?><unattend xmlns="urn:schemas-microsoft-com:unattend">

 

Thus missing a "CRLF" at the first entry.

 

I have to change the parameter to "3" to get the proper result (equal to the original file):


Like this:

<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">

 

I Just wanted to know if this is normal and related to "__XML_MiscProperty_DomVersion" function, or not.

Because I can keep the "3" to produce the same result. And in fact this is only a glitch (they are both valid to the best of my knowledge) .

 

Nonetheless I do have another more serious issue. Apparently Microsoft is creating special XML's when using WSIM for "SynchronousCommand wcm:action" :

For their own parsing code they require the both " and ' to be represented by &quot; and &apos;  , just to differentiate from their own XML code. 

                <SynchronousCommand wcm:action="add">
                    <Order>1</Order>
                    <Description>Never Expires</Description>
                    <CommandLine>cmd /C WMIC USERACCOUNT WHERE &quot;Name=&apos;TESTUSER&apos;&quot; SET PasswordExpires=FALSE</CommandLine>
                    <RequiresUserInput>false</RequiresUserInput>
                </SynchronousCommand>

 

Unfortunately while using the functions  "_XML_Load" and then "_XML_SaveToFile" all data containing ([&quot;] and [&apos;]) get back to (" and '), resulting in:

 

                <SynchronousCommand wcm:action="add">
                    <Order>1</Order>
                    <Description>Never Expires</Description>
                    <CommandLine>cmd /C WMIC USERACCOUNT WHERE "Name='TESTUSER'" SET PasswordExpires=FALSE</CommandLine>
                    <RequiresUserInput>false</RequiresUserInput>
                </SynchronousCommand>

 

I know this is "kind" of normal, but is there any way to avoid this? I mean keeping the original Raw data? 

 

Thanks in advance,

Regards.

 

 

 

Edited by fjorger

Share this post


Link to post
Share on other sites
4 hours ago, fjorger said:

Hi TheXman,

. . .

While opening Windows SIM "unattend.xml" files using your "XML.au3" UDF (By the way great work by picking up "eltorro" code and adding extra features)

As you can see in the 1st post of this topic, this is @mLipok's UDF.  I am just an experienced user of it.  :)

Share this post


Link to post
Share on other sites
25 minutes ago, TheXman said:

As you can see in the 1st post of this topic, this is @mLipok's UDF.  I am just an experienced user of it.  :)

Hi TheXman,

Thanks for pointing that out (very silly mistake)😞

@mLipok: My sincere apologies 🤕 (and thanks for your valued work👍).

About the  " and ' to be represented by &quot; and &apos;  while using WSIM, well I discovered that works regardless ;) (using both formats), so no problem whatsoever.

So now I'm just curious about the missing ( "CRLF" at the first entry.) when using "6" instead of "3", could this be a "glitch" in the parsing code, or work as intended?

Best Regards,

FJorgeR.

 

Share this post


Link to post
Share on other sites
Posted (edited)

Can you attach the shortest script and xml file that reproduces the issue?

Update:

@fjorger

You can disregard the request for a script and test file.  I was able to recreate the issue on my workstation.  When preserving white space, I'm clueless as to why there's a difference between msxml3.dll and msxml6.dll, but there is.  :think:  As you've pointed out, the old version seems to work correctly,

Although this is purely speculation on my part, when releasing msxml6.dll, maybe there was a decision to only preserve white space starting from the XML's root element, not any white space that may occur between the XML prolog and the root element.  No matter how much white space is between the XML prolog and the root xml element, when preserve white space property is true, it is all stripped when using msxml6.dll.

Even this:

<?xml version="1.0" encoding="UTF-8"?>



<SETTINGS>


</SETTINGS>

Becomes this, when using msxml6, with the PreserveWhiteSpace property set to true:

<?xml version="1.0" encoding="UTF-8"?><SETTINGS>


</SETTINGS>

 

Edited by TheXman

Share this post


Link to post
Share on other sites
Posted (edited)

@fjorger

If you want to ensure that the XML prolog is on its own line (regardless of the MSXML version), then you can TIDY the XML and write the file using a non-XML write function:

#include <xml.au3>

example()

Func example()
    Const $XML_DATA  = _
                       '<?xml version="1.0" encoding="UTF-8"?>' & @CRLF & _
                       @CRLF & _
                       @CRLF & _
                       @CRLF & _
                       '<SETTINGS>' & @CRLF & _
                       @CRLF & _
                       @CRLF & _
                       '</SETTINGS>'

    Local $oXmlDoc
    Local $sXML

    $oXmlDoc = _XML_CreateDOMDocument()     ;Create xml object
    _XML_LoadXML($oXmlDoc, $XML_DATA)       ;Load XML
    $sXML = _XML_Tidy($oXmlDoc, "UTF-8")    ;Tidy XML
    ConsoleWrite($sXML & @CRLF)             ;Display XML
    FileWrite("test.xml", $sXML)            ;Write XML
EndFunc

Output & content of test.xml file:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<SETTINGS>


</SETTINGS>

 

Edited by TheXman

Share this post


Link to post
Share on other sites
15 hours ago, TheXman said:

Can you attach the shortest script and xml file that reproduces the issue?

Update:

@fjorger

You can disregard the request for a script and test file.  I was able to recreate the issue on my workstation.  When preserving white space, I'm clueless as to why there's a difference between msxml3.dll and msxml6.dll, but there is.  :think:  As you've pointed out, the old version seems to work correctly,

Although this is purely speculation on my part, when releasing msxml6.dll, maybe there was a decision to only preserve white space starting from the XML's root element, not any white space that may occur between the XML prolog and the root element.  No matter how much white space is between the XML prolog and the root xml element, when preserve white space property is true, it is all stripped when using msxml6.dll.

Even this:


<?xml version="1.0" encoding="UTF-8"?>



<SETTINGS>


</SETTINGS>

Becomes this, when using msxml6, with the PreserveWhiteSpace property set to true:


<?xml version="1.0" encoding="UTF-8"?><SETTINGS>


</SETTINGS>

 

Hi TheXman,

Apologies for the late reply. 

Thanks for the investigation,  you nailed it.

The mystery is now solved ;)

Share this post


Link to post
Share on other sites
4 hours ago, TheXman said:

@fjorger

If you want to ensure that the XML prolog is on its own line (regardless of the MSXML version), then you can TIDY the XML and write the file using a non-XML write function:

#include <xml.au3>

example()

Func example()
    Const $XML_DATA  = _
                       '<?xml version="1.0" encoding="UTF-8"?>' & @CRLF & _
                       @CRLF & _
                       @CRLF & _
                       @CRLF & _
                       '<SETTINGS>' & @CRLF & _
                       @CRLF & _
                       @CRLF & _
                       '</SETTINGS>'

    Local $oXmlDoc
    Local $sXML

    $oXmlDoc = _XML_CreateDOMDocument()     ;Create xml object
    _XML_LoadXML($oXmlDoc, $XML_DATA)       ;Load XML
    $sXML = _XML_Tidy($oXmlDoc, "UTF-8")    ;Tidy XML
    ConsoleWrite($sXML & @CRLF)             ;Display XML
    FileWrite("test.xml", $sXML)            ;Write XML
EndFunc

Output & content of test.xml file:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<SETTINGS>


</SETTINGS>

 

Hi again, 

Thank you very much for the function example,  but because I'm loading data from an existing xml file (_XML_Load) then I'm just changing some data (ComputerName) and dumping the data to the same file.

So I would only need the following (first line only): 

Func example()     Const $XML_DATA  = _                        '<?xml version="1.0" encoding="UTF-8"?>' & @CRLF

 

Then I would had to strip the existing (first line). But no worries, I will just force (version 3).

Thanks again for your time and help (appreciated) 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By VinMe
      Dear all, i am unable to open a xml file to excel in the "xml table format" Please help me out in where i am missing
      Local $strFileToOpen = _WinAPI_OpenFileDlg('Select xml file', @WorkingDir, 'All Files(*.*)', 1, '', '', BitOR($OFN_PATHMUSTEXIST, $OFN_FILEMUSTEXIST, $OFN_HIDEREADONLY)) Global $xlXmlLoadImportToList = 2 ; Places the contents of the XML data file in an XML table $oExcel = _Excel_Open() $oWorkbook1=$oExcel.Workbooks.OpenXML($strFileToOpen, "", $xlXmlLoadImportToList) If $strFileToOpen <> False Then     Local $oWorkbook1 = _Excel_BookOpen($oExcel, $strFileToOpen) EndIf Error i am getting is:
      ......\81e_Compare_v1.au3" (46) : ==> The requested action with this object has failed.:
      $oWorkbook1=$oExcel.Workbooks.OpenXML($strFileToOpen, "", $xlXmlLoadImportToList)
      $oWorkbook1=$oExcel.Workbooks^ ERROR
      >Exit code: 1    Time: 7.338
    • By ijourneaux
      I have been using the XML UDF successfully for sometime. I am now tring to add in error handling for some bad XML files I run into.
      $oXmlDoc = _XML_CreateDOMDocument(Default) _XML_Load($oXmlDoc,$sFileXML) ;<== ENTER XML FILE PATH HERE If @error Then ; ConsoleWrite(StringFormat("_XML_load error - @error = %s", @error) & @CRLF) ; ConsoleWrite("-" & $sFileXML & @CRLF) Exit -1 EndIf ConsoleWrite("-" & $sFileXML & @CRLF) ;If no specified nodes exist, log error and exit If Not _XML_NodeExists($oXmlDoc, "//Property") Then ; ConsoleWrite("No specified nodes exist" & @CRLF) Exit -1 EndIf ;Get number of Property nodes $oProperties = _XML_SelectNodes($oXmlDoc,"//Property/Data") $iNodeCount = @extended $oParents = $oXmlDoc.SelectSingleNode("//Property[@Name='Parents']/Data") There are no error upto this point. The XML file I am trying to handle has a Data node but when I try to
      $sParam = StringSplit($oParents.text, ";") I get a fatal error (requested action on object failed). How can I test for the problem before I try to do the string split? I tried using @error, and testing $oParents but no luck.
      Appreciate any tips.
    • By ijourneaux
      I am trying to read an XML file that looks like the following. I am particularly interested in the ParameterNames and ParameterValues
       
      I was able to read a simplier XML file using
      $oXML.load("DataForwardSettings.xml") Local $oInfos = $oXML.selectnodes("//Database") ; or //Info or //Data//Info or //Values/Info  but have not been able to read
      <?xml version="1.0"?> <Entities> <Entity RecordType="TrendData"> <Property Name="AlarmLimitsSetNumber" IsReadOnly="False" ValueType="System.Int32">8</Property> <Property Name="AnalysisParamaterSetNumber" IsReadOnly="False" ValueType="System.Int32">8</Property> <Property Name="ParameterNames" IsReadOnly="True" IsList="True" ListType="List<string>" ValueType="Array" ArrayType="System.String" Count="12">System.Collections.Generic.List`1[System.String]<Data>OVERALL|PK-PK WAVEFORM|HFD|CREST FACTOR|SYNC 1-6|1X|2X|3X-4X|FTF|BSF|BPFO|BPFI</Data></Property> <Property Name="ParameterValues" IsReadOnly="True" IsList="True" ListType="List<float>" ValueType="Array" ArrayType="System.Single" Count="12">System.Collections.Generic.List`1[System.Single]<Data>0.04706,0.27951,0.02640,4.85608,0.03494,0.01727,0.02256,0.01993,0.00207,0.00060,0.00178,0.00221</Data></Property> <Property Name="NumberOfParameters" IsReadOnly="False" ValueType="System.Int32">12</Property> <Property Name="ModifiedSinceLastDataDump" IsReadOnly="False" ValueType="System.Boolean">False</Property> <Property Name="Load" IsReadOnly="False" ValueType="System.Single">0</Property> <Property Name="RPM" IsReadOnly="False" ValueType="System.Single">140.962</Property> <Property Name="Value" IsReadOnly="False" ValueType="System.Single">-1.1E-20</Property> <Property Name="SampleID" IsReadOnly="False" ValueType="System.Int32">-626794</Property> <Property Name="Timestamp_as_String" IsReadOnly="True" ValueType="System.String">8/18/2018 2:05:33 PM</Property> <Property Name="Timestamp_as_UInt" IsReadOnly="False" ValueType="System.UInt32">1534619133</Property> <Property Name="Timestamp" IsReadOnly="False" ValueType="System.DateTime">8/18/2018 2:05:33 PM</Property> <Property Name="StorageFlag" IsReadOnly="False" ValueType="Enum" EnumType="Emerson.CSI.DataImport.MHM.TrendDataStorageType" EnumValue="2">RPM_And_Overall</Property> <Property Name="Parents" IsReadOnly="False" IsList="True" ListType="List<string>" ValueType="Array" ArrayType="System.String" Count="5">System.Collections.Generic.List`1[System.String]<Data>Database=phmhmdb4ts;C:\RBMdbsrv\CustData\4ts_online_1807.rbm;-99|Area=4TS;-494|Equipment=4THTS;-712|MeasurementPoint=D39;-780|DataCollectionSet=Normal Collection Dryer Rolls;-783</Data></Property> </Entity> </Entities> I tried switching to the XML UDF but was alittle lost in how to use it. I am particularly interested in the ParameterNames and ParameterValues.
    • By macran
      I want to generating a XML file (test.xml) like as follow:
      <?xml version="1.0" encoding="GBK"?>
      <!DOCTYPE SCHEMA SYSTEM "HGWSPZJK.dtd">  ;I can not generate this line
      <SCHEMA CRC="HGWSPZ201808_9131011571786229XM_CRC.XML" SSSQ="201808" CHSNAME="HGWSDKQD" NAME="HGWSPZ">

      <TAXPAYER CJRMC="sigmagroup" CJRDM="9131011571786229XM" CJLX="DKZK" RECORDCOUNT="411" SBRQ="2018-08-31" NSRMC="sigmagroup" SWSBH="9131011571786229XM">

      <Records>
      <Record BZ="" JKKADM="2244" JKKAMC="shanghai" SE="5907.82" TFRQ="2018-08-23" FPHM="224420181000752586-L02"/>
      <Record BZ="" JKKADM="2244" JKKAMC="shanghai" SE="4742.4" TFRQ="2018-08-21" FPHM="224420181000743016-L01"/>
      <Record BZ="" JKKADM="2244" JKKAMC="shanghai" SE="18720" TFRQ="2018-08-14" FPHM="224420181000719215-L01"/>
      </Records>
      </TAXPAYER>
      </SCHEMA>
      I use XML.UDF  
      Local $oXMLile=_XML_CreateFile(@ScriptDir&"\test.xml","",True) 
      but there is no function CreateDocumentType 
      It is no effort even I test use 
      Local $doct=$oXMLfile.CreateDocumentType("SCHEMA", null, "HGWSPZJK.dtd", null)
            $oXmlfile.appendChild($doct)
      pls help me thanks.
       
       
       
       
       
       
    • By Skeletor
      Hi All,
      This is purely an XML Language question. I need to understand how I can add a value/element in between another XML element. 
      Code below shows the XML file. The info tag has the elements already inserted.
      <Configuration xmlns="http://schemas.datacontract.org/2004/07/Modules.Reporting.DataContracts.LineItems" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <GenConf> <Info>ID, Site, Name , Site_ID</Info> </GenConf> </Configuration> Now, I want to add a value from a node group into this code. Something like below. But the example below does not work.
      Any suggestions?
       
      <Configuration xmlns="http://schemas.datacontract.org/2004/07/Modules.Reporting.DataContracts.LineItems" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <GenConf> <Info>ID, Site, a/@id, Name , Site_ID</Info> </GenConf> </Configuration> <ProductName> <a id="Windows Server"/> </ProductName>  
×
×
  • Create New...