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

Hi
I'm attempting to pass an XML file

    $xml = simplexml_load_file('test.xml');
 
   var_dump($xml);

Open in new window


Produces

\\Path\To\test.php
object(SimpleXMLElement)[1]
  public 'title' => string "My Title" (length=8)
 ........
public  'properties ' =>
           array (size=1234)
                  0=>
                    object(SimpleXMLElement)[2]
                  2=>
                    object(SimpleXMLElement)[2]
                  3=>
                    object(SimpleXMLElement)[4]

Open in new window


Before some one asks I cannot upload the xml file but it looks like this (There might be errors due to fat fingers)

<?xml version="1.0" encoding="UTF-8" ?>
<resultset  xmlns="http://example.com/" xmlns:ns2="http://example.com/path/to/file" xmlns:ns2="http://example.com/path/to/other/file">
  <title>The Searchers</title>
  <date>1956</date>
  <properties >
    <ns2:name>overview</ns2:name>
    <ns2:value  xmlns:xs="http://www.w3.org/2001/XMLSchema"  xsi:type="xs:string">As a Civil War veteran spends years searching for a young niece captured by Indians, his motivation becomes increasingly questionable.</ns2:value>
  </properties >
  <properties >
    <ns2:name>Director</ns2:name>
    <ns2:value  xmlns:xs="http://www.w3.org/2001/XMLSchema"  xsi:type="xs:string">John Ford</ns2:value>
  </properties >
  <properties >
    <ns2:name>actors</ns2:name>
    <ns2:value xmlns:xsi="http://example.com/XMLSchema" xsi:type="ns2:list">
       <ns2:entries 

Open in new window

1
Become a CompTIA Certified Healthcare IT Tech
LVL 12
Become a CompTIA Certified Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

TableProductXML(ProductID, XMLDATA)
 ------------------------
 21,
 <DataModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <ProductId>21</ProductId>
   <PType1>
     <WH>
       <WH_ID>1</WH_ID>
       <Name>Name1</Name>
       <WHL_ID>3</WHL_ID>
     </WH>
     <WH>
       <WH_ID>2</WH_ID>
       <Name>Name2</Name>
       <WHL_ID>2</WHL_ID>
     </WH>
     <WH>
       <WH_ID>3</WH_ID>
       <Name>Name3</Name>
       <WHL_ID>1</WHL_ID>
     </WH>
   </PType1>
 </DataModel>

 
How to write tsql select statement for XMLDATA value with case statement If (WH\Name = 'Name2') and (WH\ID = 2) then return True else return false
ProductID   , Result
21,     True
0
I am setting up a multiforest ldap server on Windows 2016 Server. Running the following command produces the error below: The xml file is validated via XML Validator but will not run without the error.

Ideas???




Adamsync /install  localhost:52512 Ms-AdamSyncConf.xml /logs logs\install.log

Open in new window



<Error>
Establishing connection to target server localhost:52512.

Updating configuration file on MS-AdamSyncConf.

Reading Configuration File from MS-AdamSyncConf

An error occured while attempting to open file MS-AdamSyncConf for read.

Error parsing XML File. XML document must have a top level element.

. Line 0, Position 0 in (null)

Error parsing XML File. XML document must have a top level element.

. Line 0, Position 0 in (null)

Open in new window



XML being run:

<?xml version="1.0"?>
<doc>	
 <configuration>		
  <description>sample Adamsync configuration file</description>		
  <security-mode>object</security-mode>	        
  <source-ad-name>domain</source-ad-name>		
  <source-ad-partition>dc=Domain,dc=k12,DC=MN,DC=US</source-ad-partition>
  <source-ad-account></source-ad-account>                
  <account-domain></account-domain>
  <target-dn>dc=multiforest,dc=local</target-dn>		
  <query>			
   <base-dn>dc=Domain,dc=k12,dc=k12,dc=mn,dc=us</base-dn>
   <object-filter>(objectClass=*)</object-filter>			
   <attributes>				
    <include></include>				
    <exclude>extensionName</exclude>
    <exclude>displayNamePrintable</exclude>				
    

Open in new window

0
I am attempting to set up a new multiforest ldap instance, based on the following document. The configuration goes as planned untill I attempt to run ADAMSYNC /install.

I have reduced to attributes portion of the xml file to nothing and still receive the error. Any help in understanding how to resolve this issue is appreciated.

https://www.cisco.com/c/en/us/support/docs/voice-unified-communications/unified-communications-manager-version-80/111979-ucm-multi-forest-00.html

ldifde -i -s localhost:50512 -c CN=Configuration,DC=X #ConfigurationNamingContext -f nls-091218.ldf -j c:\windows\adam\logs

ldifde -i -s localhost:50512 -c CN=Configuration,DC=X #ConfigurationNamingContext -f MS-UserProxy-Cisco.ldf -j c:\windows\adam\logs

ADAMSync /install localhost:50512 AdamSyncConfNLS.xml /log logs\install.log
Establishing connection to target server localhost:50512.
Updating configuration file on AdamSyncConfNLS.xml.
Reading Configuration File from AdamSyncConfNLS.xml
Saving Configuration File on dc=multiforest,dc=local
Attaching configuration file auxilliary class on dc=multiforest,dc=local.
An ldap error occured while saving the configuration file: No Such Attribute
An ldap error occured while saving the configuration file: No Such Attribute
Done.
Done.
0
Hi,

I want to add <br/> tag in xslt n below code.
How do we do that?
<xsl:for-each select="Features">
          <xsl:element name="Name">
            <xsl:value-of select="." disable-output-escaping="yes" />
            </br>
          </xsl:element>


        </xsl:for-each>

Open in new window


Please advise.

Regards
0
Actually in the case of web application, there will be 2 dropdownlists will be avaliable. Example: Country,City. Based on the selection of country the cities drop down list need to be populate. But actually the data from the dropdownlist are avaliable at xml file.And here populating the values from xml file need to write in LINQ Queries.

 protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            var cities = (from x in xDocument.Descendants("countries").Descendants("country")
                        where x.Value==DropDownList1.SelectedValue
                        select new { x=x.Elements("city") }).ToList();
            DropDownList2.DataSource = cities;
            DropDownList2.DataTextField = "x";
            DropDownList2.DataValueField = "x";
            DropDownList2.DataBind();
         
        }
i had written another way as well but here also iam getting count as 0
(from x in xDocument.Descendants("countries").Descendants("country").Elements("city")                          
where x.Parent.Value.ToString()==DropDownList1.SelectedValue                          select new { x=x.Value }).ToList();
i had written code as seen above. but iam getting count as 0.as the data in xml file was present. please suggest
0
My plan is to automate our current Database STIG Audit process.  I want to write a short Perl script to:

   1)  Read XML STIG File (i.e.  U_Oracle_Database_12c_V1R10_Manual-xccdf.xml)
   2)  Parse out all the STIG #s, with the accompanying SQL Query Statements
   3)  Write new ascii text output to new file

Please help me with Perl file example to do this parsing?
U_Oracle_Database_12c_STIG_V1R10_Man.xml
0
Hey

<roles>
 <role id="1" name="ABC">
    <export permission="allow" />
    <user>BOB</user>
 </role>
 <role id="2" name="DEF">
    <export permission="allow" />
    <user>BOB</user>
    <user>ANDY</user>
 </role>
</roles>

Open in new window


How do I remove all the "User" elements in the XML file?

Thanks in advance

Mike
0
After receiving great help reading an xml file that contains data sources I thought it would be simple to follow it up with reading the corresponding xml file that contains the programs that read this data.  The layout of this xml file is completely different. All I want is the value contained on each "Header Description" line. I have attached the input file. The code I modified below keeps crashing with a bad character message. I can only assume I am not parsing the file correctly. I this case I believe there are no descendants so how do I simply extract the value for Header Description? I also see the message "The ' ' character.hexadecimal value 0x20 cannot be included in a name" Now the name Header Description has space in it.  How do I work around this?

        private void btnExtract_Click(object sender, EventArgs e)
        {
            rc = 0;

            TextWriter tw = new StreamWriter(OutputFilename);

            XDocument xml = XDocument.Load(InputFilename);

            var tables = from tab in xml.Descendants("Header Description")
                         select new
                         {
                             HeaderDescription = tab.Attribute("Header Description") == null ? null : tab.Attribute("Header Description").Value,
                         };

            foreach (var tab in tables)
            {
                //
                /* Console.WriteLine("Physical Name = " + tab.PhysicalName + ", Data Source = " + tab.data_source + ",

Open in new window

0
TableProduct(ProductID, ProductName)
---------------------------------------------------------
21                      Product21
22                      Product22

TableProductXML(ProductID, XMLDATA)
------------------------
21,
<DataModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <ProductId>21</ProductId>
  <PType1>
    <WH>
      <WH_ID>1</WH_ID>
      <Name>Name1</Name>
      <WHL_ID>3</WHL_ID>
    </WH>
    <WH>
      <WH_ID>2</WH_ID>
      <Name>Name2</Name>
      <WHL_ID>2</WHL_ID>
    </WH>
    <WH>
      <WH_ID>3</WH_ID>
      <Name>Name3</Name>
      <WHL_ID>1</WHL_ID>
    </WH>
  </PType1>
</DataModel>

TableWarehouse(WH_ID, Location)
-------------------------
1                          NJ
2                          NY
3                          CT

Looking for TSQL result as below

ProductId      ProductName      WH_Id      WH_Name      WHL_Id      WH_Location
21                     Product 21                     1      Name1                     3                    CT
21                     Product 21                     2      Name2                     2                     NY
21                     Product 21                     3      Name3                     1                     NJ
0
CompTIA Security+
LVL 12
CompTIA Security+

Learn the essential functions of CompTIA Security+, which establishes the core knowledge required of any cybersecurity role and leads professionals into intermediate-level cybersecurity jobs.

I've used Ron de Bruin's Custom UI Editor for a while now, and looking at my xml code you can see I'm not expert. I simply started years ago with his sample file and modified it (very carefully) to my needs.

I've used it in several projects and never had a problem. But this latest one has me stumped. I created an excel workbook with the attached VBA code as I always do, then modified an existing Custom UI project as always. But although as far as I can tell I've done everything exactly as I have in the past, I'm getting an error stating "Cannot run the macro 'ixxxxxxxxx'. The macro may not be available in this workbook or all macros may be disabled"

The trust settings are correct; allow all macros and VBA access. I thought perhaps I had fat-fingered some code somewhere so I used Custom UI Editor to generate the callbacks and they were identical to what I had, but I used them anyway.

I can run all of the subroutines from the macro window with no problem, but I'm at my wits' end trying to figure out what's wrong with my code this time around.

Any help would be greatly appreciated. I'll include my UI xml code and my vba code as well. I'm sure it's probably something simple, but for the life of me I can't find it.Mortgage-Analysis-VBA.vb.txtMortgage-Analysis-UI-Code.txt

As you can see, I haven't even changed the icons in the UI code. I haven't made it that far.
0
I have this snippet of code that reads an xml file. All works well with one exception. If any of the elements with a tag have something other than [0-9] or [A-Z] the value comes back as blank.   One of the elements has a dash, ('-'), in it so those names all come back blank. I see the same thing with parentheses, left '(' or right ')' plus quotation marks will cause this. Is there any way to correct this? I cannot change the values inside the xml file.

       private void btnExtract_Click(object sender, EventArgs e)
        {

            TextWriter tw = new StreamWriter(OutputFilename);

            XmlDocument xml = new XmlDocument();
            xml.LoadXml(InputFilename);


            if (xml.LastChild.Attributes != null)
            {
                foreach (XmlAttribute prop in xml.LastChild.Attributes)
                {
                    switch (prop.Name)
                    {
                        case "PhysicalName":
                            OPhysicaladdress = prop.Value;
                            break;

                        case "OResident":
                            OResident = prop.Value;
                            break;
                        case "data_source":
                            ODatasource = prop.Value;
                            break;
                        case "name":
                            OName = prop.Value;
                            break;
                    }
                }
   …
0
Hi,

I have the following XML after converting from JSON to XML :

<json>
  <metadata>
    <result>1</result>
    <reason>Zone Serialized</reason>
    <version>1</version>
    <command>dumpzone</command>
  </metadata>
  <data>
    <zone>
      <record>
        <ttl>86400</ttl>
        <Line>1</Line>
        <type>:RAW</type>
        <raw>; cPanel first:11.36.1.5 (update_time):1535217363 Cpanel::ZoneFile::VERSION:1.3 hostname:main.internet-webhosting.com latest:74.0.6</raw>
      </record>
      <record>
        <type>:RAW</type>
        <Line>2</Line>
        <ttl>86400</ttl>
        <raw>; Zone file for 170.26.8.103.in-addr.arpa</raw>
      </record>
      <record>
        <ttl>14400</ttl>
        <Line>3</Line>
        <type>$TTL</type>
      </record>
      <record>
        <name>170.26.8.103.in-addr.arpa.</name>
        <serial>2013042202</serial>
        <Line>4</Line>
        <ttl>86400</ttl>
        <expire>3600000</expire>
        <type>SOA</type>
        <retry>7200</retry>
        <class>IN</class>
        <refresh>86400</refresh>
        <mname>cns1.internet-webhosting.com</mname>
        <minimum>86400</minimum>
        <rname>report.internet-webhosting.com</rname>
        <Lines>6</Lines>
      </record>
      <record>
        <raw />
        <type>:RAW</type>
        <Line>10</Line>
        <ttl>86400</ttl>
      </record>
      <record>
        <nsdname>cns1.internet-webhosting.com</nsdname>
        <name>170.26.8.103.in-addr.arpa.</name>
        

Open in new window

0
Hi all,

I need an xslt to convert HTML to CSV. I know there are other ways to convert but I have a process which only accept xslt to convert HTML to CSV.
I am attaching source HTML file and csv file i want, can some one please create xslt for me. Appreciate any help on this since this is an urgent requirement and i am new to xslt.

Essentially below file lines of the csv files are 1 on 1. and you can get them in the body part pasted below.

Total Transactions:,245
Successful Transactions:,243
Failed Transactions:,2
Duplicate Transactions:,0
Unprocessed Transactions:,0
Transaction,Error Message,Details

 <body>
        <div class="container-fluid">
          <h4>Upload Summary</h4>
          <div class="row">
            <div class="col-md-4">
              <table class="table table-bordered table-striped table-condensed">
                <tr>
                  <td>
                    <b>Total Transactions:</b>
                  </td>
                  <td align="right">245</td>
                </tr>
                <tr>
                  <td colspan="2">
                    <hr/>
                  </td>
                </tr>
                <tr>
                  <td align="right">
                    <b>Successful Transactions:</b>
                  </td>
                  <td align="right">243</td>
                </tr>
                <tr>
                  <td align="right">
                    <b>Failed Transactions:</b>
        …
0
I need to create a combined Windows 10 custom taskbar and custom start menu xml file to use with group policy.

Here is the path Computer Configuration > Administrative Templates >Start Menu and Taskbar > Start Layout

I've combine the two on one xml file, but when I run it the start menu changes are undone. Here is what it looks like:

<LayoutModificationTemplate
xmlns:defaultlayout="http://schemas.microsoft.com/Start/2014/FullDefaultLayout"
xmlns:start="http://schemas.microsoft.com/Start/2014/StartLayout" Version="1"
xmlns="http://schemas.microsoft.com/Start/2014/LayoutModification">
  <LayoutOptions StartTileGroupCellWidth="6" />
  <DefaultLayoutOverride>
    <StartLayoutCollection>
      <defaultlayout:StartLayout GroupCellWidth="6" />
    </StartLayoutCollection>
  </DefaultLayoutOverride>

  xmlns:taskbar="http://schemas.microsoft.com/Start/2014/TaskbarLayout"
    Version="1">
  <CustomTaskbarLayoutCollection PinListPlacement="Replace">
    <defaultlayout:TaskbarLayout>
      <taskbar:TaskbarPinList>
        <taskbar:DesktopApp DesktopApplicationLinkPath="#leaveempty"/>
      </taskbar:TaskbarPinList>
    </defaultlayout:TaskbarLayout>
  </CustomTaskbarLayoutCollection>
</LayoutModificationTemplate>
0
Need to create a page in WordPress that would connect to the API and display a search form and list of items from an external API:

Example that needs to be achieved:

http://www.pharmachoice.com/health-advice/medical-conditions

Info about Webservices:

Conditions
Specification: http://webservice.mediresource.com/mridisease.asmx?WSDL

URL: http://webservice.mediresource.com/mriDisease.asmx?op=GetDiseaseInfo

Changeable Variables:
•      strDiseaseInput – any text string (ie. cancer, blood, nose, etc.)
•      intDiseaseID – disease id
•      strAlpha – letter of the alphabet (ie. a, b, c, etc.)

Set Variables
•      intChannelID = 0
•      intLanguageId = 0 (English) / 1 (French)
•      intCountryID = 0
•      strWsKey = {removed}
•      intCaptureOne = 0
•      intCaptureTwo = 0
•      intCaptureThree = 0
•      intCaptureFour = 0
•      intCaptureFive = 0

I have not had the chance to work with API's in the past, so any insight will be very helpful.

Thank you very much!
0
Using Delphi XE8 I get errors all the time when compiling a project:

1. [CreateAndroidManifestFile Warning] android:hardwareAccelerated attribute not found. Please review AndroidManifest.template.xml
2. [PAClient Error] Error: E2312 Unable to execute '"C:\Users\Public\Documents\Embarcadero\Studio\16.0\PlatformSDKs\android-sdk-windows\build-tools\21.1.2\Aapt.exe" package -f -M "D:\myprograms\NEW\Delphi\Test\Android\Debug\Clicked\AndroidManifest.xml" -F "D:\myprograms\NEW\Delphi\Test\Android\Debug\Clicked\bin\Clicked-unsigned.apk" -I "C:\Users\Public\Documents\Embarcadero\Studio\16.0\PlatformSDKs\android-sdk-windows\platforms\android-21\android.jar" -S "D:\myprograms\NEW\Delphi\Test\Android\Debug\Clicked\res" -A "D:\myprograms\NEW\Delphi\Test\Android\Debug\Clicked\assets" "D:\myprograms\NEW\Delphi\Test\Android\Debug\Clicked\library" "D:\myprograms\NEW\Delphi\Test\Android\Debug\Clicked\classes"' (Error 1)

[PAClient Error] Error: E2312 D:\myprograms\NEW\Delphi\Test\Android\Debug\Clicked\AndroidManifest.xml:1: error: Error parsing XML: not well-formed (invalid token)

How to solve the problems with this Manifest XML? I didn't input Api keys and all other keys at testing stage. What needs to be done to get rid of this Manifest problems?

Thanks for help.
0
Hello Experts,
Can you explain to me how to use a Digital Certificate programmatically:
I need to send electronic invoices on XML format
all is ready I just need orientation on how to sign digitally each XML file programmatically.

I have never used DC before and from what I can see on youtube
 it's a software that you operate manually per each file...
This is not practical for us since my customer makes almost a thousand sales per day using our app.
The idea is to have our app use the DC programmatically
Regards,
0
Hi,

I am trying to pass a div id from XSL to Java script to open the value of div in a modal pop up.
I used the following code - http://jsfiddle.net/uKaBH/
Only difference between the code in this jsfiddle and mine is, I need to do it for multiple div values. PFB a sample of my code.

<html lang="en">
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <meta charset="utf-8">
      <title>jQuery UI Dialog - Default functionality</title>
      <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"><script src="http://code.jquery.com/jquery-1.9.1.js"></script><script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script><link rel="stylesheet" href="/resources/demos/style.css"><script>
          $(function() {
            $( "#{$AID}" ).dialog({autoopen: false});
            $( "#{$AID}" ).dialog("close");
          });
          $(document).ready(function() {
            $('#{$CID}').click(function() {
              $( "#{$AID}" ).dialog({ modal: true });
            });
          });
        </script></head>
   <body>
      <div class="section">
					<div colspan="4" class="sectionHeader">
						<b>Attachments</b>
					</div>
					<xsl:for-each select="/file/notes/note">
					   <table width="100%" class="clsGridTableBase">
							<tr>
                                <xsl:variable name="CID" value="generate-id()"/>						
								<td id="{$CID}" title = "Click to View Content">
				

Open in new window

0
Rowby Goren Makes an Impact on Screen and Online
LVL 12
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

I have a situation where I need to have an fo:block-container with multiple columns (column-count="4") inside an fo:table-cell The fo:block-container contains a few elements when I have 2 or three fo:blocks within the container everything works fine and the content is displayed properly within the table cell. When I have many fo:blocks in the fo-container the content of the fo:block-container pops out of the table cell and displays on the following page. How can I ensure that the block-container with its content displays within the relevant fo:table-cell? Actually it seems that the whole containing table-row is getting pushed to the second page although there is a lot of space to have that table-row on the same page with the previous row. I should also add if I have fo:block-container column-count="1" it works properly when the count is > 1 the weird positioning happens
0
sourcefolder  : C:\zipto\
backupfolder : C:\Zipto\archive
i have xml files in folder..
files 1.xml, 2.xml, 3.xml
want to zip it make the file name 1.zip, 2.zip.3.zip
after sucessfull zip it should move the source file alone to backup folder with 1.xml_DDMMYYYY_HHMMSS
activities must log file logfile
can help to share script...
0
HEllo,

I have an xml wihich i am try to extract data from.  It looks like this:

declare @xmlData xml = '
<BPSD-registret><Measurement2018>
<naza_bpsd><CarePlan>Hi</CarePlan>'+
  '<Actions>'+
    '<Current>'+
      '<Action>'+
        '<id>124</id>'+
        '<msr_id>405397</msr_id>'+
        '<activity>qdq</activity>'+
        '<when>d</when>'+
        '<where>qdw</where>'+
        '<how>dsf</how>'+
        '<whom>sdfsdf</whom>'+
        '<duration>sdfsdf</duration>'+
        '<estimations>'+
        '<estimation>2</estimation>'+
        '</estimations>'+
        '<measures/>'+
      '</Action>'+
      '<Action>'+
        '<id>125</id>'+
        '<msr_id>405397</msr_id>'+
        '<activity>Aaaa</activity>'+
        '<when>jklj</when>'+
        '<where>lk</where>'+
        '<how>jlk</how>'+
        '<whom>j</whom>'+
        '<duration>lkj</duration>'+
        '<estimations>'+
          '<estimation>1</estimation>'+
        '</estimations>'+
        '<measures>'+
          '<measure>1</measure>'+
          '<measure>2</measure>'+
          '<measure>3</measure>'+
        '</measures>'+
      '</Action>'+
    '</Current>'+
    '<Previous/>'+
  '</Actions>'+
'</naza_bpsd>'+
'</Measurement2018></BPSD-registret>' ;

Open in new window


I can extract and save the content of each <action> node using the following code:

insert into BPSD_MeasurementActions
select
a.value('(activity)[1]', 'nvarchar(500)' ) as act_Activity,
a.value('(when)[1]', 'nvarchar(500)' ) as act_When,
a.value('(where)[1]', 'nvarchar(500)' ) as act_Where,
a.value('(how)[1]', 'nvarchar(500)' ) as act_How,
a.value('(whom)[1]', 'nvarchar(500)' ) as act_With,
a.value('(duration)[1]', 'nvarchar(500)' ) as act_HowLong
from @xmlData.nodes('/BPSD-registret/Measurement2018/naza_bpsd/Actions/Current/Action') Actions(a)

Open in new window


The table BPSD_MeasurementActions has an identity column called Id (Integer).  

The problem is that the node <measures> has now been added to the xml.  I need to save the values of each <measure> node.   Therefore there is a one to many relationship with the <action> node and i need to save these values in a details table.  The value of Id from BPSD_MeasurementActions will be the foreign key.

Any sugestions on how i can traverse this xml and do the appropriate insertions?
0
Using below code
CREATE TABLE #Student (
	StudentID		INT,
	ProgramID		INT,
	Email			VARCHAR(25),
	GPA				FLOAT,
	GradYear		INT
)

CREATE TABLE #Program (
	ProgramID		INT,
	Title			VARCHAR(25)
)

INSERT INTO #Program
(ProgramID, DeptID, Title)
VALUES
(1, 10, 'Mechanics'),
(2, 20, 'Computers')

INSERT INTO #Student
(StudentID, ProgramID, Email, GPA, GradYear)
VALUES
(1, 1, 'aaaa@test.com', 3.0, 1999),
(2, 1, 'bbbb@test.com', 4.00, 2000),
(3, 2, 'test@test.com', 3.5, 2001)

SELECT 
	 Student.StudentID AS 'Student/ID'
	,Program.Title AS 'Student/Program'
	,Student.Email
	,Student.GPA AS 'Info/gpa'
	,Student.GradYear AS 'Info/Year'
FROM #Program AS Program
INNER JOIN #Student AS Student ON Student.ProgramID = Program.ProgramID
WHERE Title = 'Mechanics'
FOR XML PATH ('Student'), ROOT('Students')

DROP TABLE #Program
DROP TABLE #Student

Open in new window

I'm trying to get result
<Students>
	<Student ID="1" Program="Mechanics" >
		<EmailAddress>aaaa@test.com</EmailAddress>
		<Info>
			<Gpa>3.0</Gpa>
			<Year>1999</Year>
		</Info>
	</Student>
	<Student ID="2" Program="Mechanics" >
		<EmailAddress>bbbb@test.com</EmailAddress>
		<Info>
			<Gpa>4.0</Gpa>
			<Year>2000</Year>
		</Info>
	</Student>
</Students>

Open in new window

0
I have created a program to make some XML files used to export data from our local system to another system. I used xsd.exe on Visual Studio 2010 to generate C# classes based on XSD schemas that I received from the other system. One of the types of data that are exported are clients. Now, the problem is that the XML files contain too much data. They have this structure (I have replaced some of the data with xx to not leak sensitive client data):
 
<?xml version="1.0" encoding="utf-8"?>
<ROWSET xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="Clients">
 <rOWField>
  <BI_CLIENTS>
   <CLIEREFINDIVIDU>xxxx</CLIEREFINDIVIDU>
   <CLIENACEBUSINESS>Wholesale xxxx</CLIENACEBUSINESS>
   <CLIENACECODE>xx</CLIENACECODE>
   <CLIECOUNTRYCODE>DNK</CLIECOUNTRYCODE>
   <CLIEEMAIL>xx</CLIEEMAIL>
   <CLIEZIP />
   <CLIEADDRESS>xx</CLIEADDRESS>
   <CLIECITY>xx</CLIECITY>
   <CLIENAME>xx</CLIENAME>
  </BI_CLIENTS>
  <BI_CLIENTS>
...
</rOWField>
<ROW>
  <CLIEREFINDIVIDU>xx</CLIEREFINDIVIDU>
  <CLIENACEBUSINESS>Wholesale xx</CLIENACEBUSINESS>
  <CLIENACECODE>xx</CLIENACECODE>
  <CLIECOUNTRYCODE>xx</CLIECOUNTRYCODE>
  <CLIEEMAIL>xx</CLIEEMAIL>
  <CLIEZIP />
  <CLIEADDRESS>xx </CLIEADDRESS>
  <CLIECITY>xx</CLIECITY>
  <CLIENAME>xx</CLIENAME>
 </ROW>
</ROWSET>

Open in new window

I want to have only the <ROW></ROW> data, not the <BI_CLIENTS>  </BI_CLIENTS> data, so that the data can be imported correctly in the other system. I have attached the code for the generated C# class.
Please help. I am not asking for at complete solution, just for some help to find the right place to change the code.
clients.cs
0
I have the following xml input and I want to iterate through each Flight grouped by OanD

<root>
	<Data>
		<Flight OanD="ODC1" CnxxIndicator="Y">
			<Depart>
				<CityCode>MUC</CityCode>
			</Depart>
			<Arrive>
				<CityCode>TXL</CityCode>
			</Arrive>
			<Carrier>
				<AirlineCode>TT</AirlineCode>
				<FlightNumber>2036</FlightNumber>
			</Carrier>
		</Flight>
		<Flight OanD="ODC1">
			<Depart>
				<CityCode>TXL</CityCode>
			</Depart>
			<Arrive>
				<CityCode>FRA</CityCode>
			</Arrive>
			<Carrier>
				<AirlineCode>TT</AirlineCode>
				<FlightNumber>187</FlightNumber>
			</Carrier>
		</Flight>
		<Flight OanD="ODC2">
			<Depart>
				<CityCode>FRA</CityCode>
			</Depart>
			<Arrive>
				<CityCode>MUC</CityCode>
			</Arrive>
			<Carrier>
				<AirlineCode>TT</AirlineCode>
				<FlightNumber>94</FlightNumber>
			</Carrier>
		</Flight>
	</Data>
</root>

Open in new window



The desired output xml :

<Response>
	<OriginDestination>
		<Flight OanD="ODC1" CnxxIndicator="Y">
			<AirlineCode>TT</AirlineCode>
			<FlightNumber>2036</FlightNumber>
			<Departure>
				<AirportCode>MUC</AirportCode>
			</Departure>
			<Arrival>
				<AirportCode>TXL</AirportCode>
			</Arrival>
		</Flight>
		<Flight OanD="ODC1">
			<AirlineCode>TT</AirlineCode>
			<FlightNumber>187</FlightNumber>
			<Departure>
				<AirportCode>TXL</AirportCode>
			</Departure>
			<Arrival>
				<AirportCode>FRA</AirportCode>
			</Arrival>
		</Flight>
	</OriginDestination>
	<OriginDestination>
		<Flight OanD="ODC2">
			<AirlineCode>TT</AirlineCode>
			<FlightNumber>94</FlightNumber>
			<Departure>
				<AirportCode>FRA</AirportCode>
			</Departure>
			<Arrival>
				<AirportCode>MUC</AirportCode>
			</Arrival>
		</Flight>
	</OriginDestination>
</Response>

Open in new window



My current snippet of code is below but it's not building desired results. I tried the Muenchian method to group by but it'd only retrieve unique OanD and not group them so I can get the Flights found within the group.

<xsl:key name="OandD" match="/root/Data/Flight" use="@OanD" />

  
<xsl:apply-templates select="Data"/>


<xsl:template match ="Data">

 <OriginDestination>  
 
         <!--<xsl:for-each select="Flight[generate-id() = generate-id(key('OandD', @OanD))]">-->

       <xsl:for-each select="Flight">    
	   
			//do something
			
	   </xsl:for-each>


 <OriginDestination>  
  
</xsl:template>

	

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).