423,131 Members | 2,110 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,131 IT Pros & Developers. It's quick & easy.

xmlns attributes are added automatically to nodes

P: 1
I'm new to xml and having an issue listed below:

I have a sample xml file:

<?xml version="1.0" encoding="utf-8"?>
<tt xml:lang="en" xmlns="http://www.w3.org/ns/ttml" xmlns:tts="http://www.w3.org/ns/ttml#styling"
xmlns:ttp="http://www.w3.org/ns/ttml#parameter" xmlns:ttm="http://www.w3.org/ns/ttml#metadata"
ttp:profile="http://www.netflix.com/ns/ttml/profile/nflx-tt" ttp:frameRate="24"
ttp:frameRateMultiplier="1000 1001" ttp:dropMode="nonDrop" ttp:timeBase="smpte">
<head>
<styling>
<style xml:id="style.default" tts:fontFamily="Arial" tts:fontSize="100%" tts:fontStyle="normal" tts:fontWeight="normal" tts:backgroundColor="transparent" tts:color="white" />
</styling>
<layout>
<region xml:id="region.after.center" tts:displayAlign="after" tts:textAlign="center" tts:origin="10% 10%" tts:extent="80% 80%" />
</layout>
</head>
<body>
<div xml:lang="en">
<p begin="00:03:14:09" xml:id="p62" end="00:03:16:23" region="region.after.center" style="style.default">And that was it.<br />That was his story, right?</p>
<p begin="00:03:18:14" xml:id="p63" end="00:03:19:16" region="region.after.center" style="style.default">
<span tts:fontStyle="italic">So now...</span>
</p>
</div>
</body>
</tt>

Now I have a simple xpath : `//*[starts-with(name(),'d')]` so it selects all elements under the div tag.

The problem is when evaluating the expression against the xml, I get
`xmlns="http://www.w3.org/ns/ttml"` in all `<p></p>` tags and also I get `xmlns:tts="http://www.w3.org/ns/ttml#styling"` in all `<span></span>` tags. Bewlo is a sample result of what is returned:

<p begin="00:00:34:23" xml:id="p2" end="00:00:36:00" region="region.after.center" style="style.default" xmlns="http://www.w3.org/ns/ttml">That was his story, right?</p>
<span tts:fontStyle="italic" xmlns:tts="http://www.w3.org/ns/ttml#styling">But there’s a woman there<br /> So now...</span>

so, is there is something wrong in the xml structure itself?

when adding prefix to `xmlns="http://www.w3.org/ns/ttml"` I do not get it in `<p></p>` tags but still getting xmlns in the `<span></span>` tags.



I appreciate if someone can help me out with this. Thanks in advance
Nov 10 '17 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 921
Which tools are you using to do this?
When viewing your XML with Notepad++, and using the XML-plugin, the Xpath seems to result in what you expect
Attached Images
File Type: jpg xpath.jpg (64.5 KB, 17 views)
Jan 6 '18 #2

Post your reply

Sign in to post your reply or Sign up for a free account.