XML

20K

Solutions

13K

Contributors

Extensible Markup Language (XML) refers to the encoding of documents such that they can be read by both machines and humans. XML documents use tags to show the beginning and end of a set of data. XML is used extensively on websites to show volumes of data, and is the default for a number of office productivity suites. This topic includes discussions of XML-related technologies, such as XQuery (the XML Query language), XPath (the XML Path language), XSLT (eXtensible Stylesheet Language Transformations), XLink (the XML Linking language) and XPointer (the XML Pointer language).

Share tech news, updates, or what's on your mind.

Sign up to Post

I have an xml declared as:
declare @xmlIndata xml = '<root>
  <FromDate>2018-04</FromDate>
  <ToDate>2019-08</ToDate>
  <Period />
  <Units>
    <Unit>
      <Name>1</Name>
    </Unit>
  </Units>
  <Variables>
    <Variable>
      <Name>N05C</Name>
    </Variable>
    <Variable>
      <Name>N06A</Name>
    </Variable>
    <Variable>
      <Name>PeopleCount</Name>
    </Variable>
  </Variables>
  <Filters />
</root>'

Open in new window


I want to extract the subtree starting at the node <Variables>.  So some xml manipulation to extract the subtree and set it to @variables. Like:

declare @variables xml
set @variables = somehow select the subtree 'Variables' from xmlIndata;

Then @variables should be:
 ' <Variables>
    <Variable>
      <Name>N05C</Name>
    </Variable>
    <Variable>
      <Name>N06A</Name>
    </Variable>
    <Variable>
      <Name>PeopleCount</Name>
    </Variable>
  </Variables>'

Open in new window

seems pretty basic to be able to extract part of an xml but i cant find out how to do it.
0
Starting with Angular 5
LVL 13
Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

Hi Experts,

Firstly thank you for taking a look at my question.

I am trying to access the details of xml where the attribute = Yes.

I am trying this but it is not quite correct:

$bestmatchIndAddress = $xml->soapBody->Response->BestMatch->IndividualDetail->ContactDetails->AddressDetails['Current=Yes'];

many thanks for your help!!
0
Hi Experts!

Firstly thank you for taking a look at my question.  I am having a shocking morning and can't for the life of me work out how to get the details out of the XML data.

given this XML:

  ["soapBody"]=>
  object(SimpleXMLElement)#2 (1) {
    ["Response"]=>
    object(SimpleXMLElement)#3 (5) {
      ["@attributes"]=>
      array(2) {
        ["Version"]=>
        string(3) "1.0"
        ["Environment"]=>
        string(1) "T"
      }

How do I access the Version and Environment data?

This is what I am trying -

        $xml = new SimpleXMLElement($response);
      $consumer = $xml->xpath('//Response/Version');
      echo "<br><Br>Consumer:".$consumer;

I have worked with this before but am having a brain block this morning.

This is the current response.

Notice: Array to string conversion in C:\xampp\htdocs\illion\illion v2.php on line 55
Consumer:Array

many thanks for you help!!!
0
Hi Experts,

Firstly thank you for taking a look at my question!

Using PHP i need to access the xml body inside a soap packet.

the soap response looks like this:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
        <Response   Version="1.0" Environment="T" xmlns="http://www.dnb.com.au/Schema/CCB/1.0">
            <ConsumerHeader SegId="ERHD01" InternalReference="M20190912095903-023-000238" EnquiryType="1" UniqueCustomerReference="Test" ConsumerId="2190130" Country="AU" ProductCode="AMD3" NewFileCreated="0" IsMinor="0" HasSummary="1" HasJudgment="1" HasBankruptcy="1" HasSummons="1" HasOtherPublicRecord="0" HasDirector="0" HasFileNote="0" HasDefault="1" HasEnquiry="1" HasError="0" HasWarning="0">
                <EnquiryDate Year="2019" Month="9" Day="12" />
                <PersonName>
                    <FirstName>FirstTest</FirstName>
                    <Surname>LastTest</Surname>
                </PersonName>
            </ConsumerHeader>
            <BestMatch MatchScore="768">
                <IndividualDetail SegId="ERID01">
                    <DateFirstRecorded Year="2003" Month="6" Day="10" />
                    <Person Sex="U">
                        <PersonName>
                            <FirstName>FirstTest</FirstName>
                            

Open in new window

0
Experts,
I have a XML file that is imported into a field in our SQL2016 DB. The column is type XML.
An example of two records is:

<PatientData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <Header>
            <HeaderCD>HDR</HeaderCD>
            <FileCreationDate>20190714</FileCreationDate>
            <ServiceYear>2019</ServiceYear>
            <ServiceMonth>07</ServiceMonth>
      </Header>
      <Patients>
            <Patient>
                  <MemID>XYZ</MemID>
                  <FirstName>SANTA</FirstName>
                  <LastName>CLAUS</LastName>
                  <DOB>19001225</DOB>
                  <Gender>M</Gender>
                  <SickReasons>
                        <SickReason>AZ</SickReason>
                  </SickReasons>
            </Patient>
            <Patient>
                        <MemID>ABC</MemID>
                        <FirstName>EASTER</FirstName>
                        <LastName>BUNNY</LastName>
                        <DOB>19050704</DOB>
                        <Gender>M</Gender>
                        <SickReasons>
                              <SickReason>ZA</SickReason>
                        </SickReasons>
                  </Patient>
</Patients>
<Trailer>
      <TrailerCD>TRL</TrailerCD>
      <FileCreationDate>20190714</FileCreationDate>
      <RecCnt>2</RecCnt>
</Trailer>
</PatientData>

We are able to either get the Header info to return, the Trailer info to return or the Patient Data to return.  What are we doing wrong? We don't have a lot of experience with XML.
The examples online we are finding aren't helping.

Any assistance is appreciated.
Currently this is what we have:


DECLARE @XML AS XML, @hDoc AS INT, @SQL NVARCHAR (MAX)

SELECT @XML = RAWXML FROM DevWork.MY_XML_INPUT

EXEC sp_xml_preparedocument @hDoc OUTPUT, @XML


SELECT  MemID, …
0
HI this is a continuation of thread from before
old thread

the conditions for this project has changed a little rendering the script that Michelangelo had provided no longer useful for my cause although it worked for the previous purpose

heres what changed:
the files in questions are XML format (but are not named .xml they are .901 files)
i need to remove a whole node from the *.xml files ,  including the tag

i.e.
 <errsql yadadayda > 
random sql error the statement has terminated
</errsql>

this whole line need to be removed form the file

here is a snippet of the xml file:

<chgsql ts="07:01:58.971" op="O" jb="ADD" tb="CLL_TAB" sc="BATCH"> <fld fd="F1000" af="PAL"/>
<fld fd="F1148" af="43000135163"/>
<idx fd="F1577" af="5167599565"/>
<idx fd="F1578" af="LINK"/>
<fld fd="F1001" af="1"/>
<fld fd="F902" af="00003814"/>
</chgsql>
<errsql ts="07:01:58.986" op="O" lv="50" ob="">
<sql>INSERT INTO CLL_TAB [F1000,F1148,F1577,F1578,F1001,F902] VALUES [:F1000,:F1148,:F1577,:F1578,:F1001,:F902] </sql>
<prm>PAL,43000135163,5167599565,LINK,1,00003814,</prm>
</errsql>
<chgsql ts="07:01:58.986" op="O" jb="ADD" tb="CLL_TAB" sc="BATCH">
<fld fd="F1000" af="PAL"/>
<fld fd="F1148" af="43000135164"/>
<idx fd="F1577" af="5166282554"/>
<idx fd="F1578" af="LINK"/>
<fld fd="F1001" af="1"/>
<fld fd="F902" af="00003814"/>
</chgsql>
0
I have to update an XML column across several hundred thousand records in SQL Server 2014
I am using a set-based approach as follows:

;WITH XMLNAMESPACES(DEFAULT 'http://www.my-company.co.uk/mcshema1/1.0')
UPDATE C
      SET
      [Xml].modify ('replace value of (/MC/Family/Parents/Parent[@id={ sql:column("_pc.ParentId") }]/Children/Child[@id={ sql:column("_pc.ChildId") }]/Type)[1]/text()[1] with "Special Child"')
FROM [MC].[Family] C
CROSS APPLY
(
      SELECT
            __p.[FamilyId]
            ,__p.[ChildId]
            ,__p.[ChildType]
            ,__p.[ParentId]
            ,__p.[FamilyXml]
      FROM #FamilyParent __p
      WHERE __p.[FamilyId] = C.[Id]
)_pc

but keep getting the error:

Msg 2209, Level 16, State 1, Line 334
XQuery [MC.Family.Xml.modify()]: Syntax error near '{'
0
Hi,

I'm new to xml.  May I know whether there exist any xml generator in the market?  No matter it need to pay or it is free of charge.

That is, if I provide the generator all those schema for the xml together with the data that need to be contained in the xml, the generator will generate the appropriate xml out.   Do such xml generator exist in the market?

Kindly please help.

Cheers
Stanley
0
I am trying to fill a combo Box with a list of items from a SQLite DB.
have been using/following with this https://docs.microsoft.com/en-us/windows/uwp/data-access/sqlite-databases#choose-an-abstraction-layer

SO in my
DataAcsess.cs Class i have
 public static List<String> ProductList()
        {

            List<String> entries = new List<string>();

            using (SqliteConnection db =
                new SqliteConnection("Filename=DataStorage.db"))
            {
                db.Open();

                SqliteCommand selectCommand = new SqliteCommand
                    ("SELECT DOTProductname from QPL", db);

                SqliteDataReader reader = selectCommand.ExecuteReader();

                while (reader.Read())
                {
                    entries.Add(reader.GetString(0));
                }
            
                db.Close();             
              
            }

            return entries;
        }

Open in new window



(which I am not sure what it is doing)

then i have a

I have my XAML:
                    <ComboBox  x:Name="PName" HorizontalContentAlignment="Center" MinWidth="140" ItemsSource="{Binding}">

                    </ComboBox>
           

Open in new window


(not sure how i get the item source to work)

and finally my

XAML.CS code:
            
  private void ProductList(object sender, RoutedEventArgs e)
        {
          ComboBox.ItemsSource = DataAccess.ProductList();
        }

Open in new window


Which is throwing some errors because i am not understanding what is required.

How is the standard method to get the query convert it to a item
and then put a foreach item loop to add to my combo box or similar?
appreciate your help in advance.
0
I re-organized my UWP app. I created a set of folders in the solution explorer and moved the XAML files around accordingly.
I go to recreate my menu items and i run into a trouble where it doesn't recognize some of the new folders and some of the new files.
Is there a way to clean out the old references to make way for a new one? see pictures for details
Screenshot--84-1.pngScreenshot--86-1.png
0
Become a Certified Penetration Testing Engineer
LVL 13
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Hi EE,

This question is more of a query looking for approaches to resolve the following issue:

The user has an SSRS 2016 report and filters the datasets efficiently with filters they have been given.

However, the user wants to save specific rows within the report to key the data into another system e.g Desktop application. Exporting initial the result set data to XML result is a simple task. My question is can you have a button on the SSRS which launches a subform that asks what rows /columns specifically do you want to save from the resultset in XML format.  Completing the necessary criteria on the subform, SSRS exports the data to the user via a download.  

Is this possible in SSRS if so are there examples out there?

Any links or tips, advice are welcome.

Thank you.
0
THis is a duplicate question that i asked on a reddit subforum.
but without much response.
https://www.reddit.com/r/UWP/comments/cth82z/is_it_just_me_or_is_there_not_1_single_good_guide/

Iv been looking for weeks to find a comparable guide on using a UWP app with SQLite. All the guides i find are either out of date or using nugget packages that no longer exist. or provide super complex methods.

Im using VS 2019 Community

with this: https://www.nuget.org/packages/Microsoft.EntityFrameworkCore.Sqlite/

Trying to connect to a local .DB file

Maybe i am just not googling the correct words?

Does anyone know of a good resource that demonstrates how to connect to a local .DB file submit entry's and retrieve entry's?
0
I've been following this guide: https://blogs.msdn.microsoft.com/appconsult/2018/05/06/using-the-navigationview-in-your-uwp-applications/

I have my Menu items together and they act great!
However when I open the app I am having trouble setting the default view I have made a homepage when the app opens I would like the homepage to display. When using the code line in the guide it throws an exception. Screenshot:Screenshot--57-.pngHere is the code in the guide:
   
       if (item is NavigationViewItem && item.Tag.ToString() == "Home_Page")
          {
                nvTopLevelNav.SelectedItem = item;
                break;
          }
      }

Open in new window


hopefully its something simple i am doing wrong. my homepage location is Views.HomePage

Screenshot of landing page.
Screenshot--71-.png
Full code (abit messy i know):
 MainPage.xaml

<Page
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:RussMenu"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:Custom="using:Microsoft.Toolkit.Uwp.UI.Controls"
    x:Class="RussMenu.MainPage"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    <Grid>
        <NavigationView x:Name="nvTopLevelNav"
                Loaded="nvTopLevelNav_Loaded"
                

Open in new window

0
Hi,

I have an XML file on Oracle EBS Server. I need to read the XML file and get the data into Oracle Tables
0
Hi,

I'm now having a new task which is completely new to me.  My boss asked me to grab data from an xml file which send to us on a daily basis.  I'm completely new to xml.  I find web scraping tools on the internet seems relevant to the task that I need to handle.  I also find lxml y using Python may help to solve my case.

May I know whether any short and concise (not as detail as encyclopedia) notes and materials which come with sample Python codes (at least a sample code skeleton) which demonstrate how to code scraping xml data by using lxml library under Python?

Or, if some other libraries which can do the job better than lxml under Python, that will also be welcome.  But, currently, due to license issue, I can only use Python as the programming language or Excel VBA.

Kindly please help.

Cheers!
Stanley
0
Hello All,

A project has come up to on demand scan a uploaded document for viruses in our site.
 
Some info on our site:
C#, MVC system with razor templates and xml configurations for custom UI.
AWS hosted web server and db.
Currently the users can attach documents to various items in our system.  Those documents are stored as varbinary in the db tables.


It was suggested to me to look into Clamav.net, but I'm wondering what the best solution (tool) other than Clamav, would be for scanning of a file that goes directly into a db table and not a folder structure on the server?  If it is necessary to save the file in a folder structure in order to do the scanning then we can change the system to do that.

Thank you for your time and suggestions.

Sincerely,
Ex
0
Hi EE,

I have the following query to try find missing indexes via the query store:

WITH XMLNAMESPACES (DEFAULT 'http://schemas.microsoft.com/sqlserver/2004/07/showplan')
SELECT qsqt.query_sql_text,
rts.plan_id,
rts.NumExecutions,
rts.MinDuration,
rts.MaxDuration,
rts.AvgDuration,
rts.AvgReads,
rts.AvgWrites,
qsp.QueryPlan,
qsp.QueryPlan.value(N'(//MissingIndex/@Table)[1]',
'NVARCHAR(256)') AS TableName,
qsp.QueryPlan.value(N'(//MissingIndex/@Schema)[1]',
'NVARCHAR(256)') AS SchemaName,
qsp.QueryPlan.value(N'(//MissingIndexGroup/@Impact)[1]',
'DECIMAL(6,4)') AS ProjectedImpact,
ColumnGroup.value('./@Usage',
'NVARCHAR(256)') AS ColumnGroupUsage,
ColumnGroupColumn.value('./@Name',
'NVARCHAR(256)') AS ColumnName
FROM sys.query_store_query AS qsq
JOIN sys.query_store_query_text AS qsqt
ON qsqt.query_text_id = qsq.query_text_id
JOIN (   SELECT query_id,
CAST(query_plan AS XML) AS QueryPlan,
plan_id
FROM sys.query_store_plan) AS qsp
ON qsp.query_id = qsq.query_id
JOIN (   SELECT qsrs.plan_id,
SUM(qsrs.count_executions) AS NumExecutions,
MIN(qsrs.min_duration) AS MinDuration,
MAX(qsrs.max_duration) AS MaxDuration,
AVG(qsrs.avg_duration) AS AvgDuration,
AVG(qsrs.avg_logical_io_reads) AS AvgReads,
AVG(qsrs.avg_logical_io_writes) AS AvgWrites
FROM sys.query_store_runtime_stats AS qsrs
GROUP BY qsrs.plan_id) AS rts
ON rts.plan_id = qsp.plan_id
CROSS APPLY qsp.QueryPlan.nodes('//MissingIndexes/MissingIndexGroup/MissingIndex/ColumnGroup') AS t1(ColumnGroup)
CROSS APPLY 

Open in new window

0
I have a package that loads 300 tables from DB2 to SQL Server.  We added a column to all the DB2 tables to keep track of changes named DW_LASTTIME.  
My question is, each table has a data flow task with the source table having a variable like this to pull the data.

"SELECT * FROM ABC WHERE LASTTIME >= " +  @[User::strAdjLastRunTime] +" WITH ur"

Open in new window


So I need to update all 300 to make it say

"SELECT * FROM ABC WHERE DW_LASTTIME >= " +  @[User::strAdjLastRunTime] +" WITH ur"

Open in new window

Is there any way to do this without having to manually open and update each dataflow?  Like in a text editor or something?  I know SSIS packages are just XML files but I was told if you mess with the actually file, it can corrupt it.

Thanks!

Jim
0
Can someone tell me how to use xml explicit to output this query in format below please?
select cast(C.InitialCardID as bigint) as HouseholdCard, '1' as ProgramType, '100' as adjustment from WM_CustomerSurvey a
                        JOIN  customers b on a.CARD_NUMBER = cast(b.initialcardid as bigint) and InitialCardTypeID = 0
                        INNER JOIN CUSTOMERS C ON B.HHPK = C.CustomerPK
                        where a.SURVEY_TYPE = 'Online' and a.COUPON_AWARDED = 'N'

Open in new window


Results from query looks like this.
HouseholdCard      ProgramType      adjustment
40203346685      1                              100
40201842120      1                              100
40201045770      1                              100
40990430836      1                              100
40200895929      1                              100
40201498594      1                              100

output needs to look like this
<PointsAdjust programid='1'>
      <![CDATA[40205235000,1,10
      40205234773,1,155
      40203346685,1,100
      40201842120,1,100
      40201045770,1,100
      40990430836,1,100
      40200895929,1,100
      40201498594,1,100
      ]]>
</PointsAdjust>
0
Learn SQL Server Core 2016
LVL 13
Learn SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

Hi,
How to prevent xml external entity (xxe)  through C#

StringReader a= new StringReader(b);
a= new XmlTextReader(a);
reader.XmlResolver = null
 <<<<<<Security tool is reporting here that possible of XXE mitigation>>>>>>>>>>>>>>>>
 
i applied
StringReader a= new StringReader(b);
a= new XmlTextReader(a);
a.XmlResolver = null;
a.DtdProcessing = DtdProcessing.Prohibit;
bool b = a.Read();

am not getting any value in a.
0
Any idea what may cause this error in java xml transformer

 [OPERATION FAILED] Fatal error occurred during XSLT transformation: javax.xml.transform.TransformerException: org.apache.xpath.domapi.XPathStylesheetDOM3Exception: Prefix must resolve to a namespace

I have very limited java knowledge (too long ago to mention) so just looking for general possibilities..
0
I need to generate an XML document based on the result of a database query (ADOQuery).
Is it appropriate to use a TXMLDocument component and if so how would I do this ?
I am writing a VCL application for windows using Embarcadero C++ builder XE 10.1 Berlin
0
Hi Experts,

I have problems with one new trust.
I created the trust with an xml file.
But when I test the trust I always get the following error, see the next message.

But when I test the metadat-link in IE I can download the file -> default-SP from the other site.

What is wrong here ?
0
Hi Everyone!  I got tired of endlessly searching google so I thought I'd sign up and ask this here.  I'm by no means an expert, but I'm trying to find some help adding code to my code to get these google map markers to update every 1-5 seconds, without any flashing and without a page refresh.

This code is fairly complete I think but any advise is always welcome to make it better.

<!DOCTYPE html >
  <head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>MADAR with Google Maps</title>
    <style>
      /* Always set the map height explicitly to define the size of the div
       * element that contains the map. */
      #map {
        height: 100%;
      }
      /* Optional: Makes the sample page fill the window. */
      html, body {
        height: 100%;
        margin: 0;
        padding: 0;
      }
      
    </style>
  </head>

<html>
  <body>
  
    <div id="map"></div>

    <script>
      var customLabel = {
        status: {
          label: ''
        },
        alert: {
          label: 'A'
        }
      };

        function initMap() {
        var map = new google.maps.Map(document.getElementById('map'), {
          center: new google.maps.LatLng(37.6458, -97.4543),
          zoom: 5,
          
          styles: [
            {elementType: 'geometry', stylers: [{color: '#242f3e'}]},
            {elementType: 'labels.text.stroke', stylers: 

Open in new window

0
Hi,
I'm using the below code as an example in Laravel 5.0 to retrieve a vehicle's history.
This works, but it seems like I'm not really utilizing laravel at all and doing it using a clunky curl setup.
Laravel 5 has a SoapClient I can include, but no clue how I'd utilize based on below.

the company I'm retrieving data from has a number of operations and a few ways to get the data ie: xml, json and soap1.2 (which is what I'm referencing).
https://partnerhub.pbsdealers.com/metadata

example below is: RepairOrderContactVehicleGet

Do you know of a better/simpler way I can utilize this API in Laravel 5?

I like the idea of the json one, but no idea how I'd use it. Or a better way of the soap approach.


		$username	= "myuser";
		$password	= "mypass";
		$pbs 		= 7111;
		
	$request = '
	<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
    <soap12:Body>
	<RepairOrderContactVehicleGet xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/PBS.PartnerHub.ServiceModel">
	<OpenDateSince>2017-01-01T00:00:00</OpenDateSince>
	<SerialNumber>'.$pbs.'</SerialNumber>
	<VehicleRef>a37cf36b-f756-4d18-bafe-7c90c750e794</VehicleRef>
	</RepairOrderContactVehicleGet>
	
	</soap12:Body>
	</soap12:Envelope>';


$requestURL ="https://partnerhub.dealers.com/soap12";
	$ch = curl_init();
	$header[] = "Content-type: 

Open in new window

0

XML

20K

Solutions

13K

Contributors

Extensible Markup Language (XML) refers to the encoding of documents such that they can be read by both machines and humans. XML documents use tags to show the beginning and end of a set of data. XML is used extensively on websites to show volumes of data, and is the default for a number of office productivity suites. This topic includes discussions of XML-related technologies, such as XQuery (the XML Query language), XPath (the XML Path language), XSLT (eXtensible Stylesheet Language Transformations), XLink (the XML Linking language) and XPointer (the XML Pointer language).