Quantcast
Channel: XML, System.Xml, MSXML and XmlLite forum
Viewing all 935 articles
Browse latest View live

Reorder XML Nodes based on schema content

$
0
0

I have a schema that I cannot control that specifies the xsd:sequence node. Example:

<xsd:schema>
   <xsd:element name="Something" type="Something_Type" /> 
   <xsd:complexType name="Something_Type">
      <xsd:sequence>
         <xsd:element ref="Item1"/>
         <xsd:element ref="Item2"/>
         <xsd:element ref="Item3"/>
      </xsd:sequence>
   </xsd:complexType>
</xsd:schema>

I also have a piece of xml coming out of another system like this:

<Something>
   <Item3>A</Item3>
   <Item1>B</Item1>
   <Item2>C</Item2>
</Something>

As you can see the elements are in the wrong order so the xml is not valid. Is there a way to progomatically re-order the nodes so they are in the correct order? This is obviously a very simple example and the real schema and file are very large. Thanks


Is MSMXL6.dll compatible with win 10?

$
0
0

Hi,

We are migrating form win 7 to win 10. Can you please confirm if MSXML6.dll is compatible with Win 10. 

Best Regards

Alagu

ServerXMLHTTP HTTPS / SSL Problem

$
0
0

I am having a great deal of difficulty trying to get an *.asp page to execute("post") back to an HTTP / SSL page.  I have seen this error repeated all over the Internet.  I have a valid certificate and have set up IIS accordingly.  I have also turned down the security settings on my browser, installed msxml6 on the server and I still get the following error:

 

msxml6.dll error '80072f0c'

A certificate is required to complete client authentication

/YUMTest/httpstest/send_jp.asp, line 20

 

On the server, windows 2k, I have two different sites set up.  One is the fully qualified domain name and the second is on port 8080.  The files load on either of the sites but will give the error above as long as the #####.send(); is in place.  This is all running in JScript but I have also tried in VBScript with more or less the same results.  Here is the code I am using to do a basic post but gives the error everytime it loads the page:

 

 

<%@ Language=JScript %>
<% 
 Response.Write("testing.");
 
 var request = Server.CreateObject("Msxml2.ServerXMLHTTP.6.0");
 request.setOption(3) = "(My common name)";
 
 request.open("POST", "
(the SSL/HTTPS serve)", false, "LOGIN", "PASSWORD") 

 //request.setOption(2) =  "13056";
 
 request.setRequestHeader("Content-Type", "text/xml");
 request.send();
 
 Response.Write("testing.")
%>

<html>
<body></body>
</html>

 

Any help would be greatly appreciated.

 

Thanks,

select ... for xml, server side query from web page on vb

$
0
0

Hi,

I have a select like this:

select quarto "propr1",

(select  primo "prop2",

secondo "prop3",

terzo "prop4"

from mytable  for xml  path('Spesa'),  type)  "prop5"

 for xml PATH('precom'), ELEMENTS  XSINIL

that work fine on MS Managenent Studio.

I would like to obtein the xml result file on a web page and save it on client using vb.

Where can I find same examples? 

Many thanks in advance

Marco Dell'Oca



xml:lang on for XML doc comments?

$
0
0

Is there a (non-hacky) way to get XML documentation to generate with a root level xml:lang="en-US" attribute?

I would like my XML docs to have <doc xml:lang="en-US"> in them automatically instead of just <doc>.

Updating XML Data into SQL database

$
0
0
I would like to know is there a way i can update XML data into my SQL database automatically. For example if i was to make changes in the database can it be done auto instead of manually.

Get text before start tag in xml file using xpath in c#

Using XSL to access and modify elements from a predefined array of element names

$
0
0

Pretty new to XML/XSL. I need to process an XML file, using XSL through Access VBA.
In the .xsl I have defined the elements I want to target. Everything works ok to the point where I want to replace:

<xsl:template match="element_1"> 

with

<xsl:template match="$variable">
... which is illegal in xsl 1.0. Here is my code this far:

The XML:<?xml version="1.0" encoding="UTF-8"?><test><element_1>111</element_1><element_2>222</element_2><element_3>333</element_3></test>

The XSL:
<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:msxsl="urn:schemas-microsoft-com:xslt"
  version="1.0"><!-- Make a raw RTF (result tree fragment) --><xsl:variable name="elements"><elem name="element_1" /><elem name="element_2"/><elem name="element_3"/></xsl:variable><!-- Convert to usable node-set (array variable) --><xsl:variable name="theElements" select="msxsl:node-set($elements)/elem"/><!-- Do the copy of the DOM --><xsl:template match="node()|@*"><xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy></xsl:template><!-- Here I need to match each of the elements in the array theElements --><!-- and perform operations on them, like adding an attribute --><!-- <xsl:template match="$variable"> is illegal --><!-- Code below selects the values in theElements in order, but how to use each selected value to match each element? --><xsl:for-each select="$theElements"><xsl:value-of select="@name"/> <!-- element_1, element_2 etc ... --></xsl:for-each></xsl:stylesheet>


Best regards, George



Require one of two values to allow a specific state

$
0
0

Hi,

Working on TFS PBI workflow.  I need to allow the user to select a state only when another field has one of two values.  Here's the scenario:

Our state field has a Pre-Production value.  When the user selects this state, I only want to allow the form to be saved if the Testing Status field is either "No Testing Required" or Tested.  The Testing Status field is a drop down.  

I'm somewhat of a newbie to XML so please bear with me.  It appears that the WHEN condition might work but I'm not sure how to set it up.  Should it be on the Transition element or the Field element?  And how does one set it up this condition?


TIA for your help.

format a simple table with XLST

$
0
0

I'd like to format a simple table so that it is 9pt Arial throughout the entire table. The following works, except the rows are not 9pt. New to XSLT.

Here is my XSLT:

<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/"><html><body><p><font size="2" color="red"><font face="Arial"><p>Last Names in CRM</p><table border="1"><tr bgcolor="#81BEF7"><th style="text-align:left;font-family:Arial;font-size:9pt">Last Name</th><th style="text-align:left;font-family:Arial;font-size:9pt">First Name</th><th style="text-align:left;font-family:Arial;font-size:9pt">Job Title</th><th style="text-align:left;font-family:Arial;font-size:9pt">Email Address</th><th style="text-align:left;font-family:Arial;font-size:9pt">Telephone</th><th style="text-align:left;font-family:Arial;font-size:9pt">Mobile Phone</th><th style="text-align:left;font-family:Arial;font-size:9pt">Parent Customer</th></tr><xsl:for-each select="Contacts/Customer"><tr ><td ><xsl:value-of select="LastName"/></td><td><xsl:value-of select="FirstName"/></td><td><xsl:value-of select="JobTitle"/></td><td><xsl:value-of select="EmailAddress1"/></td><td><xsl:value-of select="Telephone1"/></td><td><xsl:value-of select="MobilePhone"/></td><td><xsl:value-of select="ParentCustomerIdName"/></td></tr></xsl:for-each></table></body></html></xsl:template></xsl:stylesheet>
It's a tag which is very simple. The header row and title are fine, the text of the table is in a larger font. Any tips are appreciated. Thank you.


John


Compute Price changes of Product code and summary of volume using XSLT

$
0
0

There are multiple factories in inventory. We need to compute & transform data by factory, Product and Price Change.

Let say Product Code ‘5’ have the price change from  1.00 to 1.10.so we need sum the quantity of Price 1.0 as a one row and sum of quantity of price 1.10.

In above example Product code 5 and Price 1.0 contains two rows (i.e. Quantity 30+quantity 10).Total Qty is 40 for product code 5 in Factory 1000

Similarly Product code 5 and Price 1.10 contains 2 rows (i.e. Quantity 10+quantity 10). Total Qty is 20 for product code 5 in Factory 1000.

Last Transaction of each Product code/site TransdateTime to be change like Date ddmmyyyy

And Time ‘235959’

We want to implement below requirement using custom xslt.Can you please help how to do using XSLT

Sample Input XML Structure

<Factory>  <!—Repeated Factory Details>

 <FactoryID>100</FactoryID>

<Transaction>

 <ProductCode>5</ProductCode>

 <Quantity>30.000</Quantity>

 <UnitPrice>1.000</UnitPrice>

 <Amount>30.00</Amount>

<DateTime>2016-08-10T14:38:38</DateTime>

  </Transaction>

<Transaction>

 <ProductCode>29</ProductCode>

 <Quantity>990.000</Quantity>

 <UnitPrice>1.211</UnitPrice>

 <Amount>1198.89</Amount>

<DateTime>2016-08-10T15:38:38</DateTime>

  </Transaction>

<Factory>

FactoryID

ProductCode

Quantity

UnitPrice

Amount

TransDateTime

00140201

5

30.000

1.000

30.000

2016-08-10T14:38:38

00140201

29

990.000

1.211

1198.890

2016-08-10T14:51:22

00140201

5

30.000

1.000

30.000

2016-08-10T15:38:38

00140201

29

30.000

1.211

36.330

2016-08-10T15:51:22

00140201

5

10.000

1.050

10.500

2016-08-10T15:51:22

00140201

5

10.000

1.120

11.200

2016-08-10T16:38:38

00140201

5

20.000

1.120

22.400

2016-08-10T18:38:38

00140201

29

30.000

1.150

34.500

2016-08-10T19:51:22

00335001

3

75.000

1.119

83.925

2016-08-10T14:38:38

00335001

5

75.000

1.300

97.500

2016-08-10T15:38:38

00335001

3

75.000

1.119

83.925

2016-08-10T15:38:39

00335001

5

10.000

1.300

13.000

2016-08-10T15:50:38

00335001

5

10.000

1.100

11.000

2016-08-10T16:05:38

Expected Output data:

Record Tag

FactoryID

Item ID

ddmmyyyy  - Date

Time(hhmmss)

volume Usage

Price Break

R

00140201

5

10082016

153838

60.000

1.000

R

00140201

5

10082016

155122

10.000

1.050

R

00140201

5

10082016

235959

30.000

1.120

R

00140201

29

10082016

155122

1020.000

1.211

R

00140201

29

10082016

235959

30.000

1.150

R

00335001

3

10082016

235959

150.000

1.119

R

00335001

5

10082016

155038

85.000

1.300

R

00335001

5

10082016

235959

10.000

1.100

 


Get self closing tag through xpath in xml file in c#

$
0
0

Can you please tell me how to get this

my code: var varSearchTerm2 = from x in xDocFile.XPath2SelectElements("//xref[not(node())][not(@*)]") select x;`

Input :

<xref/>
<xref></xref>
<xref></xref>

my output look like this:

<xref/>

remove only text except tag in xml file using regular expression in c#

Using Javascript in XSLT

$
0
0

Hi,

I am having trouble running an XSL transformation with embedded javascript. It works fine under the Visual Studio XSLT debugger but when run in my application, it fails with E_FAIL. There may be better solutions than Javascript but I want to learn why it doesn't work, and what to do about it.

Following the samples I found in the Internet (and after some trial-and-error), I wrote this:

<xsl:stylesheet version="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:js="http://something.org">

<msxsl:script language="JavaScript" implements-prefix="js">
function myfunc(tm) {...}
</msxsl:script>

...

<xsl:template ...>
<xsl:value-of select="js:formatted_time(js:myfunc(string(MyTag)))" />
</xsl:template>


xmlns:msxsl="urn:schemas-microsoft-com:xslt" comes directly from example XSLT code.

I put it xmlns:js="http://something.org" because otherwise, the XSL processor would complain that namespace js is not declared. I don't know whether this is the right way to do it but it works.

I tested the transformation in Visual Studio 2012, using its built-in XSLT debugger, and it worked. Then I fed it into my application.

The application is written in non-managed C++ and uses the COM interface to msxml, instantiating three MSXML2::DOMDocument60 objects for input, transformation, and output. After loading input and transformation with data, it calls the transformNodeToObject method of the input document, supplying the transformation object and the IDispatch interface of the output document as arguments.

The operation returns E_FAIL and this error text: "Security settings do not allow the execution of script code within this stylesheet." Research led me to some places on the Internet saying I should insert this call:

setProperty(L"AllowXsltScript", VARIANT_TRUE);

I am unsure for which of my DOMDocument60 objects I should use this call; to be on the safe side, I do it for all of them. Now the error code is still E_FAIL but the description text is empty.

What am I doing wrong?

How to structure and access and xml file?

$
0
0

Basic XML stuff... but new to me.

I am developing a simple scheduler which has an ON and OFF event for each of the 7 days of the week and 6 "zones". The configuration is stored in an XML file called xmlSchedulerConfigFile. 

What is the best way to:

1. Structure the XML file?

Here's a preliminary XML file structure.

<?xml version="1.0"?><SchedulerConfigFile><Days><DayOfWeek>Monday</DayOfWeek><Zone1ON>8:00 AM</Zone1ON><Zone1OFF>6:00 PM</Zone1OFF><Zone2ON>8:00 AM</Zone2ON><Zone2OFF>6:00 PM</Zone2OFF><Zone3ON>8:00 AM</Zone3ON><Zone3OFF>6:00 PM</Zone3OFF><Zone4ON>8:00 AM</Zone4ON><Zone4OFF>6:00 PM</Zone4OFF><Zone5ON>8:00 AM</Zone5ON><Zone5OFF>6:00 PM</Zone5OFF><Zone6ON>8:00 AM</Zone6ON><Zone6OFF>6:00 PM</Zone6OFF></Days><Days><DayOfWeek>Tuesday</DayOfWeek><Zone1ON>8:00 AM</Zone1ON><Zone1OFF>6:00 PM</Zone1OFF><Zone2ON>8:00 AM</Zone2ON><Zone2OFF>6:00 PM</Zone2OFF><Zone3ON>8:00 AM</Zone3ON><Zone3OFF>6:00 PM</Zone3OFF><Zone4ON>8:00 AM</Zone4ON><Zone4OFF>6:00 PM</Zone4OFF><Zone5ON>8:00 AM</Zone5ON><Zone5OFF>6:00 PM</Zone5OFF><Zone6ON>8:00 AM</Zone6ON><Zone6OFF>6:00 PM</Zone6OFF></Days>.....etc.

2. How do I access a specific Day/Zone (i.e. Monday, Zone1OFF) and return the text value of the time stored there?

Any suggestions and/or specific examples would be greatly appreciated.



Thx, MikeH



XML Deserialize Error

$
0
0

Hi, I have a WinForm application that passes datasets back and forth through a WCF service.  I have hundreds of clients using this application without any issues however, there is one that keeps getting this message:

There is an error in XML document (1, 147).

I have spent countless hours researching and cannot seem to figure out why one client would receive these messages on a regular basis (some others do get it by very rarely).

Here is the full stack trace.

Message: There is an error in XML document (1, 147).
Source: System.Xml
Stack Trace:    at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle)
   at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
   at Common.AppWebWebReference.AppWeb.Invoke(String typeName, String methodName, Byte[] data, TupleOfintstringstringstringbooleanstringbooleanTupleOfintintcd6ORBnm employee)
   at Common.WebServiceProtocol.<>c__DisplayClass7`2.<Invoke>b__3(AppWeb service)
   at Common.BasicAuthSoapHttpClient.CallWithRetry[TResponse](Func`2 callToMake)
   at Common.WebServiceProtocol.AppWebHandler[TResponse](Func`2 funcOperation)
   at Common.WebServiceProtocol.Invoke[T,TU](Boolean runAsync, String type, String method, TU[]& byrefs, Object[] parameters)
   at BackOfficeLogic.GroupLogic.GetMemberGroup(Int32 groupId)
   at CommonUI.Controls.MemberGroupFilter..ctor()
   at UI.ReportsModule.ReportControls.MemberReportFilter..ctor()
   at UI.ReportsModule.ReportControls.MemberReportSettingFilter.btnBrowse_Click(Object sender, EventArgs e)
Target Site: Module - C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll Method: Deserialize
Inner Exception: 
Message: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
Source: System
Stack Trace:    at System.Net.GZipWrapperStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   at System.IO.StreamReader.ReadBuffer(Char[] userBuffer, Int32 userOffset, Int32 desiredChars, Boolean& readToUserBuffer)
   at System.IO.StreamReader.Read(Char[] buffer, Int32 index, Int32 count)
   at System.Xml.XmlTextReaderImpl.ReadData()
   at System.Xml.XmlTextReaderImpl.ParseText(Int32& startPos, Int32& endPos, Int32& outOrChars)
   at System.Xml.XmlTextReaderImpl.ParseText()
   at System.Xml.XmlTextReaderImpl.ParseElementContent()
   at System.Xml.XmlTextReaderImpl.Read()
   at System.Xml.XmlTextReader.Read()
   at System.Xml.XmlTextReaderImpl.InitReadElementContentAsBinary()
   at System.Xml.XmlTextReaderImpl.ReadElementContentAsBase64(Byte[] buffer, Int32 index, Int32 count)
   at System.Xml.XmlTextReader.ReadElementContentAsBase64(Byte[] buffer, Int32 index, Int32 count)
   at System.Xml.Serialization.XmlSerializationReader.ReadByteArray(Boolean isBase64)
   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read12_InvokeResponse()
   at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer1.Deserialize(XmlSerializationReader reader)
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)

Does anyone have any ideas on how I can troubleshoot this?  Since it is isolated to one client, I believe it may be due to their local network or ISP however I am not sure.

C#4.0: To delete all nodes of an XML file

$
0
0

Hello

I have an XML file:

<?xml version="1.0" encoding="UTF-8" ?>
- <dataroot xmlns:od="urn:schemas-microsoft-com:officedata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Test.xsd" generated="2016-09-16T22:06:41">
- <Table2><ID>1</ID><Name>A</Name></Table2>
- <Table2><ID>2</ID><Name>B</Name></Table2></dataroot>
I want to delete all of nodes.

How to convert xml file into .ini file.

$
0
0

Hi Can anyone please help me in finding a way to convert xml file to .ini file .

For eg: My file is given below.

 <?xml version="1.0" encoding="utf-8"?>
-<configuration>
-<section name="SQLSERVER2008">
 <settingname="INSTANCEID" value=""MSSQLSERVER"" />
 <settingname="ACTION" value=""Install"" />
 <settingname="FEATURES" value="SQLENGINE,REPLICATION,FULLTEXT,AS,RS,BIDS,CONN,IS,BC,SDK,BOL,SSMS,ADV_SSMS,SNAC_SDK,OCS" />
 <settingname="HELP" value=""False"" />
 <settingname="INDICATEPROGRESS" value=""True"" />
 <settingname="QUIET" value=""False"" />
 <settingname="IACCEPTSQLSERVERLICENSETERMS" value=""TRUE"" />
 <settingname="QUIETSIMPLE" value=""True"" />
 <settingname="X86" value=""False"" />
 <settingname="ENU" value=""True"" />
 <settingname="ERRORREPORTING" value=""False"" />
 <settingname="INSTALLSHAREDDIR" value=""C:\Program Files\Microsoft SQL Server"" />
 <settingname="INSTALLSHAREDWOWDIR" value=""C:\Program Files (x86)\Microsoft SQL Server"" />
 <settingname="INSTANCEDIR" value=""C:\Program Files\Microsoft SQL Server"" />
 <settingname="SQMREPORTING" value=""False"" />
 <settingname="INSTANCENAME" value=""MSSQLSERVER"" />
 <settingname="AGTSVCSTARTUPTYPE" value=""Manual"" />
 <settingname="ISSVCSTARTUPTYPE" value=""Automatic"" />
 <settingname="ISSVCACCOUNT" value=""NT AUTHORITY\NETWORK SERVICE"" />
 <settingname="ASSVCSTARTUPTYPE" value=""Automatic"" />
 <settingname="ASCOLLATION" value=""Latin1_General_CI_AS"" />
 <settingname="ASDATADIR" value=""C:\Program Files\Microsoft SQL Server\MSAS10_50.MSSQLSERVER\OLAP\Data"" />
 <settingname="ASLOGDIR" value=""C:\Program Files\Microsoft SQL Server\MSAS10_50.MSSQLSERVER\OLAP\Log"" />
 <settingname="ASBACKUPDIR" value=""C:\Program Files\Microsoft SQL" />
 </section>
 </configuration>
Now I want to convert this xml file to .ini file . Can you please help me in converting this file above into .ini file.
Any help is appreciated.
Thanks & Regards,
Fayaz.

FayazSyed

Convert xml into .INI file

$
0
0

Hi,

How can'I convert an XML file into .ini file?

Can one help me please.

LINQ XML: How to add a blank line to output xml?

$
0
0

Using the System.Xml.Linq namespace, how can I add a blank-line when writing out xml?

(for example: System.Xml.Linq.XmlComment() will write out a comment line...but I want to write a blank line)

Thanks!

Viewing all 935 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>