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

SignedXML.CheckSignature Always Fails

$
0
0
I don't think I posted my original question in the correct forum, so I'm going to close that one and post here.

I'm currently working on a project which requires the XML posts to be digitally signed. I do not seem to have any luck with getting any test posts from our client to validate with the below code:

publicstaticbool verifySignature(string xmlData)

{



    XmlDocument theDocument = new XmlDocument();

    XmlNodeList nodeList;

    SignedXml signedDocument;



    theDocument.PreserveWhitespace = true;

    theDocument.LoadXml(xmlData);

    signedDocument = new SignedXml(theDocument);



    nodeList = theDocument.GetElementsByTagName(

        "ds:Signature");



    signedDocument.LoadXml((XmlElement)nodeList[0]);



     return signedDocument.CheckSignature();



}


The posts are signed using the XML Signature tag with a namespace of "ds". I am simply base64 decoding the post and sending it straight to here without any modifications of whitespace or casing.

Any help would be greatly appreciated!

- Jake

Needing to query each repeated node for a specific child node, always getting the first node value

$
0
0

Take for example the following prototype XML layout

<records><record><valuea>foo1</valuea><valueb>bar1</valueb><valuec>bob1</valuec></record><record><valuea>foo2</valuea><valueb>bar2</valueb><valuec>bob2</valuec></record><record><valuea>foo3</valuea><valueb>bar3</valueb><valuec>bob3</valuec></record></records>

So I am using a call to .SelectNodes("//records/record") and iterating through within a For Each within the returned list.

The iteration loop count is correct.

Then I make a call to .SelectSingleNode("//records/record/valueb")

For some reason I always get the first record instance. The object the For Each has received as the iteration valuable contains the correct values, but somehow making the call .SelectSingleNode against it to obtain the specific value the program needs retrieves the always the first record's valueb. The new object the For Each returns seems to have knowledge it is actually part of a larger set of data... not the individual record from the record set.

How can I correctly iterate through the record list and obtain each distinct record's valueb?

I am coding in Access / VBA.

TIA!


Michael Lueck - Lueck Data Systems - http://www.lueckdatasystems.com/ - My Blog

Startindex cannot be less than zero when trying to create a sample xml file from a xsd file

$
0
0

Using Visual studio pro 2015

I have a xsd file and need to generate a xml sample file from it.
Ive opened the file with the XML editor. When i Try to "Generate Sample XML", I'm met with the following:

Have anyone experienced this?

Any hints or tips on how to find the fault are welcome!

brgs

Bjørn

root element missing

$
0
0

erver Error in '/rcamend2' Application.

Root element is missing.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Xml.XmlException: Root element is missing.

Source Error: 
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 
[XmlException: Root element is missing.]
   System.Xml.XmlTextReaderImpl.Throw(Exception e) +72
   System.Xml.XmlTextReaderImpl.ParseDocumentContent() +5320383
   System.Xml.XmlTextReaderImpl.Read() +163
   System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace) +112
   System.Xml.XmlDocument.Load(XmlReader reader) +107
   System.Xml.XmlDocument.LoadXml(String xml) +160
   PUBLIC_NEW_RATION_CARD_Public_RC_Amendment.btnVerify_Click(Object sender, EventArgs e) +390
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9782626
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +204
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +12
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +15
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1639


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.3282.0

XSLT 2.0 & 3.0 is support in .net

$
0
0
Hi,
We are using VS2013 and using XSLT1.0. With XSLT1.0 we are able to get the result from <g class="gr_ gr_13 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar only-ins doubleReplace replaceWithoutSep" data-gr-id="13" id="13">XML</g> file. Now we have a requirement to use XSLT2.0.
Is VS2013 or later versions have support to use XSLT2.0?
If not, Is there any alternate ways to use XSLT2.0?

Thanks,
Kiran

How to create a CSV/ excel Schema for XML

$
0
0

Hi team. i'm very new to xml/ related xml development And i Have Requirement, create a CSV / Excel (FlatfileSchema) Schema to convert CSV / Excel to xml, Can you please  advise and support to  create a CSV / Excel to create xml. 

Redefining attribute node text value using the Attribute Property and Index results in reording the attributes in the XML

$
0
0

Please refer to cross-post at: 

http://www.vbaexpress.com/forum/showthread.php?65491-Setting-quot-Text-quot-value-of-XML-Attribute-Node-Changes-Node-Index-Order


Greg Maxey Please visit my website at: http://gregmaxey.mvps.org/word_tips.htm

Transform XML to html with XSL using msado15.dll

$
0
0

I am trying to transform the XML with the following code but this is breaking at line where adding a XSL property.

Database used is SQL Server 2014

_com_error: Item cannot be found in the collection corresponding to the requested name or ordinal

#import "C:\Program Files\Common Files\System\ado\msado15.dll" no_namespace rename("EOF", "EndOfFile")

int main(int argc, char* argv[])
{
HRESULT hr = S_OK;
try
{
    CoInitialize(NULL);
    // Define string variables.
    _bstr_t strCnn("Provider=MSOLEDBSQL;DATABASE=Sample;Data Source=IS-DEV;Trusted_Connection=Yes;");

    _ConnectionPtr mAdoConn;
    _CommandPtr cmd;
    _StreamPtr outStrm;

    const char *xslfile;
    xslfile = "C:\\script\\Test_xsl\\example-html.xsl";

    _variant_t vra(DISP_E_PARAMNOTFOUND, VT_ERROR);
    _variant_t vtEmpty(DISP_E_PARAMNOTFOUND, VT_ERROR);


    hr = mAdoConn.CreateInstance(__uuidof(Connection));

    if (FAILED(hr))
    {
        printf("Failed creating record set instancen");
        return 0;
    }


    hr = mAdoConn->Open(strCnn, L"", L"", -1);

    // Set the Command
    hr = cmd.CreateInstance(__uuidof(Command));

    cmd->ActiveConnection = mAdoConn;
    hr = cmd->put_CommandTimeout(900);

    _bstr_t sqlQuery = "SELECT Id,Title,Artist,Country,Company,Price,Year FROM CDCatalog CD ORDER BY Id FOR XML AUTO";

    hr = cmd->put_CommandText(sqlQuery);

    hr = cmd->Properties->Item[L"XSL"]->put_Value(_variant_t(xslfile));

    // Set-up the output stream
    hr = outStrm.CreateInstance(__uuidof(Stream));

    hr = outStrm->Open(vtEmpty, adModeUnknown, adOpenStreamUnspecified, L"", L"");

    hr = cmd->Properties->Item[L"Output Stream"]->put_Value(_variant_t((IDispatch*)outStrm));

    hr = cmd->Properties->Item[L"Output Encoding"]->put_Value(_variant_t("utf-8")); //ISO-8859-1"));

    hr = cmd->Execute(&vra, &vtEmpty, adExecuteStream);
}
catch (_com_error &ce)
 printf("Error:%s", (char *)ce.Description());

CoUninitialize();
_getch();
return 0;




How to write XSLT using multiple input to one output xml

$
0
0
Currently have a requirement to to create a XSLT, using multiple input xml to one output xml, we need to create a one xml with the line wise data, Could you please guide and advise on this?

Reading image file from XML with CDATA tag into SharePoint online image library or Document library

$
0
0

Hi ,

Please provide ur inputs on the below requirement.

I have an XML file with an image (image/jpeg) embedded as a CDATA section. This image data i need to read and upload this image in in SharePoint image/document library.

1. Any possibility by using powershell script?

2. Any other possibility?

Thanks

Rajesh

adding countdown to boot menu

$
0
0

Hi all, I would like to add a countdown timer to the following menu below...say, 5 seconds and if no choice is selected by the user, "c" is auto selected. Can anyone help?

<?xml version="1.0" encoding="UTF-8" ?>
<Config>
    <Menu>
        <Topic Delay="-1">
            <Text>Select an item by using the keyboard:</Text>
        </Topic>
        <Entry Key="1">
            <Text>1. Acronis True Image (64-bit)</Text>
            <LoadKernel>
                <Kernel Arguments="&#32; quiet" Path="dat10.dat" />
                <Ramdisk Path="dat11.dat" />
                <Ramdisk Path="dat12.dat" />
                <Hash Path="sgn13.sgn" />
            </LoadKernel>
        </Entry>
        <Entry Key="2">
            <Text>2. Acronis System Report (64-bit)</Text>
            <LoadKernel>
                <Kernel Arguments="product=system_report quiet" Path="dat14.dat" />
                <Ramdisk Path="dat15.dat" />
                <Ramdisk Path="dat16.dat" />
                <Hash Path="sgn17.sgn" />
            </LoadKernel>
        </Entry>
        <Entry Key="c">
            <Text>c. Continue booting</Text>
            <Chainload />
        </Entry>
    </Menu>
</Config>

How to Parse XML into a C# object?

$
0
0
I used the XmlWriter to create this string:

<EventInput>
          <Group>12345</Group>
<Events>
<Event Id="100" />
<Event Id="101" />
<Event Id="102" />
<Event Id="103" />
<Event Id="104" />
</Events>
</EventInput>

What would be the simplest way to read and parse this XML string into a C# object (I'm not showing the private members and properties for simplicity)

class EventInput
{
public int group;
        public List<int> EventIds = new List<int>();
}


how to map xml data(xslt) when Element tag have xmlns

$
0
0

When i write a xslt map i have found input xml root element tag and other main element tag have a 'xmlns' (xml namespace) so i have  concern how to map data with this xmlns,  So could you please support to support to map that data. for your reference here with attached sample input file.

Input Sample xml

<?xml version="1.0" encoding="utf-8"?>
<Root xmlns="http://IntegrationAccount1.Schema16">
  <Consol_Details xmlns="">
    <ShipmentNo>Shipement_No</ShipmentNo>
    <ConsolType>Type</ConsolType>
    <TransportMode>Transport</TransportMode>
    <ContainerMode>Container Mode</ContainerMode>
    <Load1st>1st Load</Load1st>
    <LastDisc>Last Disc</LastDisc>
  </Consol_Details>
  <Consol_Details xmlns="">
    <ShipmentNo>S10219089768</ShipmentNo>
    <ConsolType>AGT</ConsolType>
    <TransportMode>SEA</TransportMode>
    <ContainerMode>FCL</ContainerMode>
    <Load1st>LKCMB</Load1st>
    <LastDisc>USJFK</LastDisc>
  </Consol_Details>
  <Consol_Details xmlns="">
    <ShipmentNo>S10219089769</ShipmentNo>
    <ConsolType></ConsolType>
    <TransportMode></TransportMode>
    <ContainerMode></ContainerMode>
    <Load1st></Load1st>
    <LastDisc></LastDisc>
  </Consol_Details>
  </Root>

expected output

<UniversalShipment xmlns="http://www.wise.lk/Schemas/Universal/2011/11" version="1.1">
  <Shipment>
    <DataContext>
      <DataTargetCollection>
        <DataTarget>
          <Type>ForwardingConsol</Type>
        </DataTarget>


      </DataTargetCollection>

      <Company>
        <Code>LK1</Code>
      </Company>
      <EnterpriseID>EXK</EnterpriseID>
      <ServerID>TST</ServerID>
      
    </DataContext>

<SubShipmentCollection>
<SubShipment>
<DataContext>
<DataTargetCollection>
<DataTarget>
<Type>ForwardingShipment</Type>
<Key>S10219089768</Key>
</DataTarget>
</DataTargetCollection>
</DataContext>
</SubShipment>
</SubShipmentCollection>

    <AgentsReference></AgentsReference>
    <AWBServiceLevel>
      <Code>STD</Code>
    </AWBServiceLevel>
    
    <ContainerMode>
      <Code>FCL</Code>
    </ContainerMode>
    <FreightRateCurrency>
      <Code>LKR</Code>
    </FreightRateCurrency>
 
   
    <PaymentMethod>
      <Code>PPD</Code>
     </PaymentMethod>
 
   
    <ScreeningStatus>
      <Code>UNK</Code>
    </ScreeningStatus>

    <ShipmentType>
      <Code>AGT</Code>
    </ShipmentType>

   
    <TotalNoOfPacksPackageType>
      <Code>PKG</Code>
    </TotalNoOfPacksPackageType>
  
   
    <TransportMode>
      <Code>SEA</Code>
    </TransportMode>
   <VesselName>  HYUNDAI VOYAGER</VesselName>
    <VoyageFlightNo>SDFDFD</VoyageFlightNo>
    <WayBillNumber>YBEU2254875099</WayBillNumber>
    <WayBillType>
      <Code>MWB</Code>
      <Description>Master Waybill</Description>
    </WayBillType>

     

    <OrganizationAddressCollection>
      <OrganizationAddress>
        <AddressType>ReceivingForwarderAddress</AddressType>
        <OrganizationCode>EXPFRECMB</OrganizationCode>        
      </OrganizationAddress>
      <OrganizationAddress>
        <AddressType>ShippingLineAddress</AddressType>
        <OrganizationCode>AIRGENSDF</OrganizationCode>
       </OrganizationAddress>
      <OrganizationAddress>
        <AddressType>SendingForwarderAddress</AddressType>
        <OrganizationCode>EXPUSACMZ</OrganizationCode>        
      </OrganizationAddress>
    </OrganizationAddressCollection>


<TransportLegCollection Content="Complete">
      <TransportLeg>
  <PortOfDischarge>
          <Code>ADALV</Code>
        </PortOfDischarge>
        <PortOfLoading>
          <Code>LKCMB</Code>
        </PortOfLoading>
      </TransportLeg>
    </TransportLegCollection>


    
  </Shipment>
</UniversalShipment>



Coding problem writing XML-Word text in Windows 10

$
0
0

Hi All,

I have distributed a C++ application that writes XML files for Word. It works fine for most of my users but for some of them the text is written as coded. For example, normally my application writes:

<w:t>1. Dati generali</w:t>

whereas for these users it writes:

<w:t>葬&#x02;$h&#x0A;&#x01;</w:t>

Since all these users run the application in Windows 10, I thought that the problem could be some settings in Windows 10 itself, so I deeply investigated in Windows Control Panel what settings could be (local language, region, etc.), but with no luck.

Any help would be greatly appreciated.

Thanks,

Gianni

Event log filter to exclude a specific Target Account Name

$
0
0

I'm currently using the following XPath filter to show logs for user account creations and deletions:

<QueryList>
  <Query Id="0" Path="Security">
    <Select Path="Security">*[System[(EventID=4720 or EventID=4726)]]</Select>
  </Query>
</QueryList>

Is there a way for me to exclude a Target Account Username (not a Subject Account Username)?  Basically, I want to see events when user accounts are created or deleted except for a specific user account.


How to get the current date in xslt, and minus this from another date?

$
0
0
Hi, I'm reading in a date/time from xml, and I'm wanting to subtract the current date from the other, and say how many hours/minutes the date is from now.

I've found the XPath Extension functions, but there doesn't appear to be any function which can minus two date/times.

How would I go about doing this?

How Can i add a wild card condition for XSLT choose

$
0
0

Currently  i have Requirement to add a wildcard condition for a Choose statement condition, i want to filter out and equal first two digit start from  'US' ,  Discharge and LoadPort tags. Below is a my own created script but its not functioninonfg, Could you  please guide me to correct this,

<xsl:for-each select="a:Root/Consol_Details">
  
<xsl:choose>
    <xsl:when test="position() = 2  and   Discharge = 'US*' ">   
 
<RecipientRoleCollection>
        <RecipientRole> 
      <Code>RAG</Code>
  </RecipientRole>
 </RecipientRoleCollection>
  
    </xsl:when>
    <xsl:when test="position() = 2  and   LoadPort = 'US*' ">   
     
<RecipientRoleCollection>
        <RecipientRole> 
      <Code>SAG</Code>
  </RecipientRole>
 </RecipientRoleCollection>
  
    </xsl:when>
  </xsl:choose>
  
</xsl:for-each>

HELP! Using Dynamic LINQ with XML...

$
0
0

i am trying to use dynamic LINQ to query an XML document, as indicated is possible on Scott Guthrie's blog post here:

http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx

below is my code sample:

-----------

XElement pViewElement = XElement.Load(...);

string sFilter = @"Convert.ToInt32(Attribute("Age").Value) >= 60)";
List<XElement> pViewResults = pViewElement.Elements().AsQueryable().Where(sFilter).ToList();

-----------

however, when this code executes, i receive the following error:

"No applicable method 'Attribute' exists in type 'XElement'"

does anyone know why this is? obviously, that method DOES exist when i write the code normally. i cannot find an XML example with dynamic LINQ anywhere. rather, the only good examples are against a SQL backend.

your help is greatly appreciated in advance.

I want to display info from an XML file on my lock screen

$
0
0

Hello,

i have an .XML file that i update daily and would like to figure out a way to display certain information in that file on my lock screen. 

More specifically, i work for a large company and we have 350+ computers that syncronize to my computer. There is an app that must be up to date and right now the managers have to log in to each computer  to make sure the app us up to date. if i could pull the date from this XML file and display it on the lock screen it would save SO much tome for my managers. 

I also have an .exe file that also shows the date. Could I use that? Or is it possible to create an app that displays the update date on the lock screen? Kind of like the Weather app that displays the weather under the date and time.

'Xslt' must be a valid XML error

$
0
0

Hi Team,

Currently i have requirement to write simple xslt and use it for Development purpose, when i create it there have format invalid issue, Could you please support to correct it, For your reference here with attached input xml and current xslt and expected output.

Input xml- 

  

<?xml version="1.0" encoding="UTF-8"?>
<ns0:utrrada_Order xmlns:ns0="http://utrrada.com/3pl/FMS/XSDLibrary">
<Orders>
   <Order>4202623821</Order>
   <DocType Variant="ZNB">PO</DocType>
   <Action>CHG</Action>

   <SoldTo>
      <ID>1000</ID>
    </SoldTo>

    <ShipTo>
      <ID>9001</ID>
    </ShipTo>

    <GoodsSupplier>
      <ID>0000602110</ID>
      <Name>NONSNOW LTD</Name>
    </GoodsSupplier>

    <Vendor>
      <ID>0000402062</ID>
      <Name>HON</Name>
    </Vendor>

 </Orders>
</ns0:utrrada_Order>

XSLT - :

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://utrrada.com/3pl/FMS/XSDLibrary" exclude-result-prefixes="ns0">
<xsl:output indent="yes" method="xml"/>
<xsl:template match="/">

<UniversalShipment xmlns="http://www.cargowise.com/Schemas/Universal/2011/11" version="1.1">
  <Shipment>
  
    <DataContext>
      <DataTargetCollection>
        <DataTarget>
          <Type>OrderManagerOrder</Type>
  <Key><xsl:value-of select="Orders/Order"/></Key>
  
        </DataTarget>
      </DataTargetCollection>

      <Company>
        <Code>USA</Code>
      </Company>
  
  <EnterpriseID>EXK</EnterpriseID>
      <ServerID>TST</ServerID>  
</DataContext>  

 
  </Shipment>
</UniversalShipment>

</xsl:template>
</xsl:stylesheet>

 expected output-

    <UniversalShipment xmlns="http://www.cargowise.com/Schemas/Universal/2011/11" version="1.1">
  <Shipment>
    <DataContext>
      <DataTargetCollection>
        <DataTarget>
          <Type>OrderManagerOrder</Type>
          <Key>4202623821</Key>
        </DataTarget>
      </DataTargetCollection>

      <Company>
        <Code>USA</Code>
      </Company>
      <EnterpriseID>EXK</EnterpriseID>
 
      <ServerID>TST</ServerID>
    </DataContext>


  </Shipment>
</UniversalShipment>

Viewing all 935 articles
Browse latest View live


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